简体   繁体   English

如何选择在C#中保存Excel文件的路径

[英]how to choose path to save excel file in C#

I am able to enter the name of the file i want to save as however, how do you add in the path of which i want to save the excel file in? 我可以输入要保存为的文件的名称,但是如何在要保存excel文件的路径中添加呢?

this is the code i use 这是我使用的代码

xlWorkBook.SaveAs(Module.Text + ".xls", Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);

With the first parameter you can not only specify the file name but also the location. 使用第一个参数,您不仅可以指定文件名,还可以指定位置。

Example: 例:

wbook.SaveAs("c:\\file_path\\file_name",  Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);

在第一个参数中,将路径添加到文件名:

book.SaveAs(@"C:\Book1.xml"...

只是可以结合您的文件路径和文件名。

xlWorkBook.SaveAs($@"c:\{Module.Text}" + ".xls", Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM