-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 –