[英]save datagrid as excel 2003 or excel 2007 using vb.net
i can save a datagrid using the vb.net code: 我可以使用vb.net代码保存一个数据网格:
saveFileDialog.Filter = "Excel2007 (*.xlsx)|*.xlsx|All files (*.*)|*.*"
i wish to give the user the option to save in either Excel2003 or Excel2007 format. 我希望为用户提供以Excel2003或Excel2007格式保存的选项。 What changes do i need to make in the code and what about references and imports?
我需要在代码中进行哪些更改以及有关引用和导入的内容? thanks...
谢谢...
Additionally to the adequate extension, you have to provide the Excel version when calling SaveAs()
: 除了适当的扩展名之外,在调用
SaveAs()
时还必须提供Excel版本:
curBook.SaveAs("full path with adequate extension", Excel.XlFileFormat.xlWorkbookDefault)
You can find the list of values for XlFileFormat
here . 您可以在此处找到
XlFileFormat
的值列表。 Although the names in this list are not too descriptive. 尽管此列表中的名称描述性不强。 Here you have a translation:
这里您有翻译:
Excel.XlFileFormat.xlExcel8
(as explained here ) Excel.XlFileFormat.xlExcel8
(如解释在这里 ) Excel.XlFileFormat.xlOpenXMLWorkbook
(as explained here ) Excel.XlFileFormat.xlOpenXMLWorkbook
(如解释在这里 ) NOTE: bear in mind that the code above relies on Office Interop
. 注意:请记住,上面的代码依赖于
Office Interop
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.