[英]How To Count The Number Of Printed Pages In Print Preview Excel with C#?
正如艾哈邁德·阿卜杜勒哈米德 (Ahmed Abdelhameed) 評論的那樣,您可以嘗試這樣做,但有一個區別 - 僅對可見工作表計算頁數:
Excel.Workbook xlWB = Globals.ThisAddIn.Application.ActiveWorkbook; // or other way you get an instance of the workbook
long pagesCount = 0;
foreach (Excel.Worksheet xlSht in xlWB.Sheets)
{
if (xlSht.Visible == Excel.XlSheetVisibility.xlSheetVisible)
{
pagesCount += xlSht.PageSetup.Pages.Count;
}
}
MessageBox.Show(pagesCount.ToString());
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.