我有一个带有Manual PageBreaks的Excel,但是excel也在添加自动Pagebreaks。我需要找到自动分页的来源。有谁可以请帮助我的代码。我不知道如何继续使用C#或Aspose。
ImageOrPrintOptions printoption = new ImageOrPrintOptions();
printoption.PrintingPage = PrintingPageType.Default;
SheetRender sr = new SheetRender(StateBasis, printoption);
int pageCount = sr.PageCount;
// MessageBox.Show(pageCount.ToString());
CellArea[] area1 = Toc.GetPrintingPageBreaks(printoption);
//MessageBox.Show(area.Length.ToString());
for (int m = 0; m < area1.Length;m++)
{
//Get the first page rows.
int strow = area1[m].StartRow;
int stcol = area1[m].StartColumn;
// MessageBox.Show("Page " + (i + 1).ToString() + " : " + CellsHelper.CellIndexToName(strow, stcol));
workBook.Worksheets["State Basis"].HorizontalPageBreaks.RemoveAt(strow);
}
答案 0 :(得分:1)
请参阅以下示例代码(使用Aspose.Cells API)来完成您的任务: 例如 示例代码:
Workbook workbook = new Workbook("e:\\test2\\Book1.xlsx");
Worksheet worksheet = workbook.Worksheets[0];
ImageOrPrintOptions printoption = new ImageOrPrintOptions();
printoption.PrintingPage = PrintingPageType.Default;
SheetRender sr = new SheetRender(worksheet, printoption);
int pageCount = sr.PageCount;
MessageBox.Show(pageCount.ToString());
CellArea[] area = worksheet.GetPrintingPageBreaks(printoption);
MessageBox.Show(area.Length.ToString());
for (int i = 0; i < area.Length; i++)
{
//Get the first page rows.
int strow = area[i].StartRow;
int stcol = area[i].StartColumn;
MessageBox.Show("Page " + (i + 1).ToString() + " : " + CellsHelper.CellIndexToName(strow, stcol));
}
我是Aspose的支持开发人员/传播者。