0
我正在使用Windows窗體應用程序,c# 我有三個數據表。 我想將第一張表格保存在excel的Sheet1中,第二張表格放在同一個excel的Sheet2中,第三張放在Sheet3中。我如何將數據錶轉換爲使用c窗體窗體中的Excel工作表#
這三張表的名稱將保持不變,如彙總,詳情和零售商。
任何人都可以請讓我知道我該怎麼做。
問候
喝罵
我正在使用Windows窗體應用程序,c# 我有三個數據表。 我想將第一張表格保存在excel的Sheet1中,第二張表格放在同一個excel的Sheet2中,第三張放在Sheet3中。我如何將數據錶轉換爲使用c窗體窗體中的Excel工作表#
這三張表的名稱將保持不變,如彙總,詳情和零售商。
任何人都可以請讓我知道我該怎麼做。
問候
喝罵
我所知道的唯一方法是使用PIA(主互操作程序集)。下面是使用PIA來創建一個Excel文件中的一些示例代碼,和幾個工作表:
ApplicationClass exApp;
Workbook book;
Worksheet sheet;
exApp = new ApplicationClass();
book = exApp.Workbooks.Add(missing);
for (int sheetnum=1; sheetnum++; sheetnum<5)
{
sheet = (Worksheet)book.Worksheets.Add(missing, missing, missing, XlSheetType.xlWorksheet);
sheet.Name = "Sheet Number: " + sheetnum.ToString();
sheet.Cells[1,1] = "Hello, I am here";
}
book.Close(true, "TestSheet.xls", null);
exApp.Quit();
有一些漁獲 - 必須運行代碼的PC上安裝Excel和Microsoft不會使用不建議在PIA的上一個服務器的原因很明顯。