小编Dar*_*rio的帖子

OpenXML sdk修改Excel文档中的工作表

我在excel中创建一个空模板.我想打开模板并编辑文档,但我不知道如何更改现有工作表.那是代码:


using (SpreadsheetDocument xl = SpreadsheetDocument.Open(filename, true)) 
{ 
WorkbookPart wbp = xl.WorkbookPart; 
WorkbookPart workbook = xl.WorkbookPart; 
// Get the worksheet with the required name. 
// To be used to match the ID for the required sheet data 
// because the Sheet class and the SheetData class aren't 
// linked to each other directly. 
Sheet s = null; 
if (wbp.Workbook.Sheets.Elements().Count(nm => nm.Name == sheetName) == 0) 
{ 
// no such sheet with that name 
xl.Close(); 
return; 
} 
else 
{ 
s = …
Run Code Online (Sandbox Code Playgroud)

worksheet openxml openxml-sdk

7
推荐指数
1
解决办法
8272
查看次数

标签 统计

openxml ×1

openxml-sdk ×1

worksheet ×1