1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
using MSOExcel2003 = Microsoft.Office.Interop.Excel;
using MSOWord2003 = Microsoft.Office.Interop.Word;
//...
public uint GetPageCount()
{
MSOExcel2003.ApplicationClass oMSOExcel2003Application;
MSOExcel2003.Workbook oMSOExcel2003Workbook;
MSOExcel2003.Sheets oMSOExcel2003Sheets;
MSOWord2003.ApplicationClass oMSOWord2003Application;
MSOWord2003.Document oMSOWord2003Document;
object oParamFileName;
object oParamMissing;
object oParamFalse;
object oParamTrue;
uint uiPageCount;
oParamMissing = System.Reflection.Missing.Value;
oParamFalse = false;
oParamTrue = true;
uiPageCount = 0;
switch (m_eInputDocType)
{
case EDocumentType.MSOExcel2003:
oMSOExcel2003Application = new MSOExcel2003.ApplicationClass();
oMSOExcel2003Application.Visible = false;
oMSOExcel2003Workbook = oMSOExcel2003Application.Workbooks.Open(m_oInput.Folder + Path.DirectorySeparatorChar + m_oInput.Filename, oParamMissing, oParamTrue, oParamMissing, oParamMissing, oParamMissing, oParamMissing, oParamMissing, oParamMissing, oParamMissing, oParamMissing, oParamMissing, oParamMissing, oParamMissing, oParamMissing);
for (int i = 0; i < oMSOExcel2003Workbook.Worksheets.Count; i++)
{
oMSOExcel2003Sheets = (MSOExcel2003.Sheets)oMSOExcel2003Workbook.Sheets[i];
uiPageCount += 1 + (uint)oMSOExcel2003Sheets.HPageBreaks.Count;
uiPageCount += (uint)oMSOExcel2003Sheets.VPageBreaks.Count;
} |
Partager