本文整理汇总了C#中SpreadsheetDocument.TryGetFirstSheetByName方法的典型用法代码示例。如果您正苦于以下问题:C# SpreadsheetDocument.TryGetFirstSheetByName方法的具体用法?C# SpreadsheetDocument.TryGetFirstSheetByName怎么用?C# SpreadsheetDocument.TryGetFirstSheetByName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpreadsheetDocument
的用法示例。
在下文中一共展示了SpreadsheetDocument.TryGetFirstSheetByName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildResourceSheet
private void BuildResourceSheet(SpreadsheetDocument doc, string tabName)
{
if (doc == null) throw new ArgumentNullException("doc");
var sheets = doc.WorkbookPart.Workbook.Sheets ?? doc.WorkbookPart.Workbook.AppendChild(new Sheets());
//Use the existing sheet in the template
Sheet sheet;
WorksheetPart worksheetPart;
SheetData sheetData;
if (!doc.TryGetFirstSheetByName(tabName, out sheet))
{
//Create new sheet if not in the tempalte
worksheetPart = doc.WorkbookPart.AddNewPart<WorksheetPart>();
var sheetId = 9999;
var rows = AddResourceColumns(doc, tabName);
sheetData = new SheetData(rows);
worksheetPart.Worksheet = new Worksheet(sheetData);
worksheetPart.Worksheet.AddMdsolNamespaceDeclaration();
sheet = new Sheet
{
Id = doc.WorkbookPart.GetIdOfPart(worksheetPart),
SheetId = (uint) sheetId,
Name = tabName
};
sheets.Append(sheet);
}
else
{
//Get the existing sheet in the template
worksheetPart = (WorksheetPart)doc.WorkbookPart.GetPartById(sheet.Id);
var rows = AddResourceColumns(doc, tabName);
sheetData = worksheetPart.Worksheet.GetFirstChild<SheetData>();
sheetData.Append(rows);
worksheetPart.Worksheet.AddMdsolNamespaceDeclaration();
}
}
开发者ID:chenghuang-mdsol,项目名称:Medidata.Cloud.Tsdv.Loader,代码行数:39,代码来源:AutoCopyrightCoveredResourcedExcelBuilder.cs