该文将详细介绍在保存excel工作簿到pdf文档时,在 pdf 结果文档中添加页码。
c#
using spire.xls;
namespace exceldemo
{
class program
{
static void main(string[] args)
{
//加载示例文档
workbook wbk = new workbook();
wbk.loadfromfile("sample.xlsx");
foreach (worksheet sheet in wbk.worksheets)
{
//&p 指page number, &n 指总页数
sheet.pagesetup.rightfooter = "&p/&n";
}
//保存文档
wbk.savetofile("result.pdf", fileformat.pdf);
}
}
}
vb.net
imports spire.xls
namespace exceldemo
class program
private shared sub main(byval args() as string)
'加载示例文档
dim wbk as workbook = new workbook
wbk.loadfromfile("sample.xlsx")
for each sheet as worksheet in wbk.worksheets
'&p 指page number, &n 指总页数
sheet.pagesetup.rightfooter = "&p/&n"
next
'保存文档
wbk.savetofile("result.pdf", fileformat.pdf)
end sub
end class
end namespace
效果图: