本文介绍了如何通过保存文件后台日志来保存新的Excel文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我正在使用此代码打开并写入exel文件,但它仅适用于已创建的文件.
我想创建一个新的Excel,然后保存我的数据.
Hello,
I''m using this code to open exel file and write, but it works only those file which are already created.
I want to create a new excel and then save my data.
myExcelApp = new Excel.ApplicationClass();
myExcelApp.Visible = false;
myExcelWorkbooks = myExcelApp.Workbooks;
SaveFileDialog save = new SaveFileDialog();
save.Filter = "Excel Files .xlsx|*.xlsx";
save.ShowDialog();
string sss = save.FileName;
String fileName = sss;
myExcelWorkbook = myExcelWorkbooks.Open(fileName, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue, misValue);
Excel.Worksheet myExcelWorksheet = (Excel.Worksheet)myExcelWorkbook.ActiveSheet;
String cellFormulaAsString = myExcelWorksheet.get_Range("A1", misValue).Formula.ToString();
string s;
int i = 1;
foreach (ListViewItem li in listView2.Items)
{
s = "A" + i.ToString();
myExcelWorksheet.get_Range(s, misValue).Formula = li.Text;
i++;
}
myExcelWorkbooks.Close()
推荐答案
这篇关于如何通过保存文件后台日志来保存新的Excel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!