-1
创建的我有代码,目前创建几个不同的excel文件,但现在我需要修改它在一个工作簿中的所有位置。我有一个函数创建工作簿。写入一个工作簿是在不同的函数中使用c#
public void startSavingProcess()
{
Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
if (xlApp == null)
{
MessageBox.Show("Oops, Excel is not properly installed on this machine.");
}
try
{
xlApp = new Microsoft.Office.Interop.Excel.Application();
xlApp.Workbooks.Add();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + " \t\t" + ex.ToString(), "Error Saving", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
我该如何去调用我以前创建的工作簿?
create_FileOne()
string newfileName = "File_" + counter + "myFileOne" + DateTime.Now.ToString("MM-dd-yy") + ".xls";
String newfilePath = System.IO.Path.GetTempPath() + newfileName;
Console.WriteLine(newfilePath);
while (File.Exists(newfilePath))
{
counter++;
newfileName = "File_" + counter + " myFileOne" + DateTime.Now.ToString("MM-dd-yy") + ".xls";
newfilePath = System.IO.Path.GetTempPath() + newfileName;
Console.WriteLine(newfilePath);
}
//xlAPP.Workbooks.Open();
有一吨的资源在那里如何添加和使用您正在使用的相同方法,从Excel工作表中删除数据。例如,这个SO帖子有两种不同的方法可以将数据添加到工作表中,其中一种使用ADO,另一种类似于当前如何使用Excel。 http://stackoverflow.com/questions/12148111/easiest-way-to-insert-simple-data-into-an-excel-file-from-net –