我正在使用Office Web components用值填充Excel模板。该模板是Excel xml格式,包含所有相关字段和布局选项,包括页面布局,在本例中为横向。我使用下面的代码用一些真实的字段填充这个模板。
Set objSpreadsheet = Server.CreateObject("OWC11.Spreadsheet")
objSpreadsheet.XMLURL = Server.MapPath("xml") & "\MR1_Template.xls"
'Fill cells with values here
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "inline; filename=" & strFileNaam
Response.write objSpreadsheet.xmlData保存新的Excel文件后,页面布局选项将消失。我查看了OWC的API文档,但找不到用于指定横向页面布局的选项
发布于 2009-10-22 16:39:46
在对模板excel sheet (as xml)和生成的xmlData进行了一些详细的比较之后,我决定在生成的Xml中修改页面布局。以下是我添加的选项:
<x:WorksheetOptions>
<x:PageSetup><x:Layout x:Orientation="Landscape"/></x:PageSetup>
<x:FitToPage/>
<x:Print>
<x:FitWidth>2</x:FitWidth>
<x:ValidPrinterInfo/>
<x:PaperSizeIndex>9</x:PaperSizeIndex>
<x:Scale>87</x:Scale>
</x:Print>
</x:WorksheetOptions>发布于 2009-10-19 11:03:01
我不确定您是否传递了正确的数据。将XSL模板传递给XMLURL似乎是一个奇怪的方法名?
如果您所做的都是xsl转换,那么为什么不像本文那样使用DOMXmlDocument呢?
http://www.codeproject.com/KB/XML/xml_spreadsheet_to_csv.aspx
剪切和粘贴以方便使用:
Dim xslt As New XslTransform
'Load the stylesheet.
xslt.Load(Server.MapPath(".") & "excel2csv.xsl")
Dim doc As New XmlDocument
'xmldata is string, use doc.Load(fileName) for file.
doc.LoadXml(xmlData)
'Create an XmlTextWriter which outputs to a file.
Dim fileName As String
fileName = Server.MapPath(".") & "book.csv"
Dim writer As XmlWriter = New XmlTextWriter(fileName, Nothing)
'Transform the data and send the output to the console.
xslt.Transform(doc, Nothing, writer, Nothing)
writer.Close()https://stackoverflow.com/questions/1578692
复制相似问题