Microsoft Office Interop Excel - 指定 Excel 文件的名称
我使用 Microsoft Office Interop Excel 创建 Excel 文件。我的问题是我不知道如何指定 Excel 文件的名称。
变量:
// Excel object references.
private Application _excelApp;
private Workbooks _books;
private _Workbook _book;
private Sheets _sheets;
private _Worksheet _sheet;
创建Excel文件:
_excelApp = new Application();
_books = _excelApp.Workbooks;
_book = _books.Add(_optionalValue);
_sheets = _book.Worksheets;
_sheet = (_Worksheet)(_sheets.Item[1]);
_sheet.Name = sheetName;
创建Excel文件时如何指定Excel文件的名称?对不起我的英语。
编辑:
我知道我可以使用
_book.SaveAs(fileName)
I use Microsoft Office Interop Excel for create excel file. My problem is that I dont know how specify name of excel file.
Variables:
// Excel object references.
private Application _excelApp;
private Workbooks _books;
private _Workbook _book;
private Sheets _sheets;
private _Worksheet _sheet;
Create excel file:
_excelApp = new Application();
_books = _excelApp.Workbooks;
_book = _books.Add(_optionalValue);
_sheets = _book.Worksheets;
_sheet = (_Worksheet)(_sheets.Item[1]);
_sheet.Name = sheetName;
How can I specify name of excel file during creating excel file? Sorry for my english.
EDIT:
I know that I can use
_book.SaveAs(fileName)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
创建 Excel 工作簿并复制所需数据后,您可以简单地将其保存为
Type.Missing 参数,该参数适合我从中获取此代码段的代码,但您可能需要包含在内。
Once you have created the Excel workbook and copies the data you want, you can simply save it as such
The Type.Missing parameters were appropriate to my code that I took this snippet from, but you may have need for inclusion.
我认为你应该检查这个< /a>.从链接页面:
i think you should check this. From the linked page: