如何在现有excel模板中的aspose单元格上打开excel工作表,并使用带有c#的asp.net在现有excel模板上编写新的excel工作表?请给我一个例子......
谢谢和问候, Parthiban K。
答案 0 :(得分:1)
我在Aspose担任社交媒体开发人员。使用以下示例代码打开现有的Excel文件并向其添加工作表。
//open the template excel file
Workbook wb = new Workbook("input.xls");
//Add new worksheet in existing workbook
Worksheet sheet = wb.Worksheets.Add("New Sheet");
//Access the "A1" cell in the sheet.
Cell cell = sheet.Cells["A1"];
//Input the "Hello World!" text into the "A1" cell
cell.PutValue("Hello World!");
//Save the Excel file.
wb.Save("output.xls");
答案 1 :(得分:0)
根据您的上一条评论,您可以使用以下代码示例将数据从数据表(数据集)导入现有工作簿中的新工作表:
//Open the existing workbook
Workbook workbook = new Workbook("book1.xls");
//add new worksheet other than the existing worksheets
Worksheet worksheet = workbook.Worksheets.Add("New Sheet");
//import data from datatable (dataset) to newly created worksheet
//dataTable is the dataset table
worksheet.Cells.ImportDataTable(dataTable, true, "A1");
//save the updated workbook
workbook.Save("book1.xls");