Hi
Doing a page break delimitation foreach cell based on the value. In this case we’ve lookup for “Order_type” value.
It’s dooing ok the page breaks on .PDF, but no effect on spreadsheets format (.ODS).
Code (and the feed file attached):
string csvRepData = $"{pathToTemp}rep-data.csv";
newReport = $"{pathToTemp}DetailFormat.ods";
TxtLoadOptions loadOptions = new TxtLoadOptions(LoadFormat.Csv);
loadOptions.Encoding = Encoding.UTF7;
#region Set Data
Workbook book = new Workbook(csvRepData, loadOptions);
Worksheet worksheet = book.Worksheets[0];
Cells cells = worksheet.Cells;
cells.DeleteRow(0);
cells.DeleteColumn(2, true);
title = "ALL ITEM DETAILS HELD FOR ORDER: "
PageSetup pageSetup = book.Worksheets[0].PageSetup;
pageSetup.SetHeader(0, "&\"Times New Roman,Bold\"ParkMap");
pageSetup.SetHeader(1, $"&\"Times New Roman,Bold\"{title}");
pageSetup.SetHeader(2, "&\"Times New Roman,Bold\"&D");
List<Cell> lstCellsPageB = new List<Cell>();
FindOptions opts = new FindOptions();
opts.LookInType = LookInType.Values;
opts.LookAtType = LookAtType.EntireContent;
foreach (Cell cell in cells)
{
if (cell.Value.ToString().Equals("Order_Type", StringComparison.OrdinalIgnoreCase))
{
lstCellsPageB.Add(cell);
}
}
foreach (var item in lstCellsPageB)
{
worksheet.HorizontalPageBreaks.Add(item.Name);
worksheet.VerticalPageBreaks.Add(item.Name);
}
newReport = pathToTemp + "ScheduleList.pdf";
book.Save(newReport, SaveFormat.Pdf);
//newReport = pathToTemp + "ScheduleList.ods";
//book.Save(newReport, SaveFormat.Ods);
rep-data.zip (1.9 KB)