HPageBreaks cannot be larger than 1024

I am opening a spreadsheet and receive an error:

"The count of HPageBreaks cannot be larger than 1024."

StackTrace: at Aspose.Cells.HorizontalPageBreakCollection.Add(Int32 row, Int32 startColumn, Int32 endColumn)


Please advise if this is an Aspose limitation, if this can be fixed, or any other workaround.

Hi,

Thanks for the file.

I have tested loading/opening the file with our latest version/fix Aspose.Cells for .NET v5.2.2.6 and it works fine.
Here is my sample code:
Workbook workbook = new Workbook(“e:\test2\IFRS SME Financials.xlsx”);
workbook.Save(“e:\test2\output.xlsx”);

Please try our latest version/fix v5.2.2.6.

Thank you.

Hi Amjad


The fix / new release works perfectly.

Thank you for the quick response.

Amjad


Sorry, my mistake.

The error is still encountered.

This happens when I save a spreadsheet via SpreadSheetGear to a Stream, then open the stream via Aspose.

Stream xlsStream = wbv.ActiveWorkbook.SaveToStream(FileFormat.OpenXMLWorkbook); Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(xlsStream);


Please advise.


Amjad


Even saving the file to disk first, then opening via Aspose has the same effect:

string tempFileName = System.IO.Path.GetTempFileName();

wbv.ActiveWorkbook.SaveAs(tempFileName, FileFormat.OpenXMLWorkbook);

Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(tempFileName);


I have checked, I am definitely using the new DLL you sent me (dated 16 Feb)

Hi,

Well, you are using SpreadsheetGear to save the file to streams for which I am not sure. But, using the standard .NET System.IO API to save the file into stream and then open the file from the stream, it works absolutely fine. Here is my sample code that works fine:

//Creating a file stream containing the Excel file to be opened
FileStream fstream = new FileStream(“e:\test2\IFRS SME Financials.xlsx”, FileMode.Open);
//Opening the Excel file through the file stream using Aspose.Cells API
Workbook workbook = new Workbook(fstream);
fstream.Close();

//Save the file.
workbook.Save(“e:\test2\output.xlsx”);

Thank you.

Hi Amjad


That the file is being saved via SpreadSheetGear just before opening it in Aspose has no relevance. That exact file I provided initially that you used for your first test was also saved with SpreadSheetGear.


I changed my code to open the file from disk, and not from a stream, but still receive the same error:

Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(tempFileName);


And that is using the DLL you sent me yesterday. On the same file I sent you yesterday.

Hi,

That is strange. I did test opening your file from the disk or streams (opening the file from System.IO namespace API), it works fine.

Please create a separate console Application writing my sample code in it with new dll file, zip it and post it here to show the issue, we will check it soon.

Thank you.

Amjad, please find a test project attached.

Hi,

Thanks for the project.

I have tested your project and checked your template file. Your file “IFRS.xlsx” has issues, for confirmation, you may simply open the file into MS Excel 2007, MS Excel does produces error messages when opening into it (See the attached screen_shot here). So, Aspose.Cells would produce the exception you have mentioned. If Ms Excel don’t have objection opening it, Aspose.Cells would also don’t give you error message. As a workaround, you may open the file into MS Excel 2007 and re-save the file or save it as. Now load/open the file with Aspose.Cells API, it works fine.

thank you.

Hi Amjad


I get the errors on my side in Excel as well now, thanks.

I understand the file is corrupt / contains corrupt data, but the error message from Aspose is slightly misleading as the issue with the file is not the HPageBreaks count, but rather from some other source.

If this error message that is thrown could be corrected it would help other developers with the same file issues to resolve them easier in the future.


Thanks for your help and quick responses. Good service.

Hi,

OK, we will investigate if we can do
something for it so, the file can be opened /loaded fine with our product. Also
if we cannot load this corrupted file, we will check if we can enhance our exception message(if possible). I have logged an issue with an id:
CELLSNET-24543. We will look into it soon.

Thanks for being patient!

Hi,

Please see, the page break’s count can’t be larger than 1024, otherwise the file will be opened with error by Microsoft Excel 2007.

Hi Shakeel


I got confirmation from other sources as well that that is why Excel reports the workbook as corrupted as well. So your error reporting is spot-on. Thanks.

Hi,

I am getting the below exception for ASPOSE.CELLS.dll
The count of HPageBreaks cannot be larger than 1024.
and if I am using the latest ASPOSE.CELLS.dll v17.12.0.0, It is giving me the exception for License.
Please let me know, how I can fix this issue or if there is any work around for the same.

Thank You.

@suyogdw,

For your information, Microsoft Office Excel has a limit of 1026 manual horizontal page breaks for a worksheet, so it is not an issue with Aspose.Cells API by any means. In fact, Limits are as follow,
XLS: 1000
XLSX: 1026
As Aspose.Cells APIs follow MS Excel’s guidelines and recommendations therefore you cannot exceed the specified limitation while using Aspose.Cells APIs. See the document on MS Excel limits and specifications for your reference.

Regarding license error, well, you may use your current license with any version of the API which is released before your subscription expiry date (i.e., 20 May 2017). But you cannot use any version which is released after your subscription expiry date. You may either upgrade your subscription or use any older version of the product which was released before 20 May 2017.

FYI, when you purchase a license for the product, you are authorized to use the license file with any new (and upcoming (official versions)) versions or hot fixes of the component for the next whole year. Moreover, your license will never expire if you continue to use your license with the product’s version/hotfix that should be released before your subscription expiry date. You may open your license file into notepad (without modifying it, lease it will not work) and check your subscription expiry date for confirmation.

Hope, this helps a bit.