gpt4 book ai didi

c# - 如何为 C# 生成的 Excel 文件创建目录?

转载 作者:行者123 更新时间:2023-11-30 18:18:42 25 4
gpt4 key购买 nike

我必须在应用程序中实现 Excel 导出,其中导出的 Excel 文件应包含第二张工作表上的目录之类的内容。

此表应引用带有页码的其他表 - 因此如果客户打印出 Excel 文件,他们可以使用此目录。

鉴于对页面大小、页边距等的一些假设,有没有人知道我应该使用哪种库来满足此要求?

或者唯一可行的方法是使用 VBA 宏计算页码?

最佳答案

如果有人感兴趣,我似乎可以使用 Aspose.Cells 来计算目录的页码:

var workbook = new Workbook("Erstfassung.xls");
var pagesSoFar = 0;

foreach (var worksheet in workbook.Worksheets)
{
var pageCount = worksheet.GetPrintingPageBreaks(new ImageOrPrintOptions()).Length;
Console.WriteLine($"{worksheet.Name} - ({pageCount} long), starts from {pagesSoFar}");
pagesSoFar += pageCount;
}

关于c# - 如何为 C# 生成的 Excel 文件创建目录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40745183/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com