Free Support Forum - aspose.com

workbook.getWorksheets().get("Sheet1").autoFitRows() throwing memory out of bounds exception with large data in the file

hi

i am using workbook.getWorksheets().get(“Sheet1”).autoFitRows() with large data in the excel file and its throwing memory exception at this point.

please look into the issue.


thanks



<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>EN-US</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–><!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman","serif";}

<![endif]–>

Hi,


Well, I am afraid, autoFitRows would surely take a certain amount of memory and time if there is a large amount of data in lots of cells in rows/columns. We do not recommend this method unless you have some custom needs for your least amount of data in the cells. We recommend you to use autoFitRow() method instead of your important rows individually.

Moreover, please make sure that you have sufficient memory assigned/allotted to JVM to process your program. Kindly make sure that you have provided and extended the JVM memory appropriately to process the workbook/worksheet etc.

Following is the command line you may use on command prompt to extend the JVM memory accordingly:

E.g

java -Xms2024m -Xmx2024m MyTestProgram

Also, please use our latest version/fix e.g v7.4.2 if you are not already using it.

If you still could not evaluate, kindly do attach your template file, we will look into your issue on our end.

Thank you.

hi amjad

i am using the function import csv to write large csv to excel sheet i am facing OutOfMemoryError: Java heap space exception

my file size is approximately 112 mb.

i am attaching the actual csv file please provide me the solution soon.

for small set of data its working fine.


thanks

Hi,


I have checked your file by opening it into MS Excel which does take some time to be opened. Your file has millions of records, so surely, it would demand lots of memory to be used for opening, auto-fitting rows and re-saving the file. I am afraid, you need to have sufficient amount of RAM allocated for the big file to be processed.

I have evaluated your issue further and the following command does work here fine. I have extended the JVM memory when running the JAVA program. I don’t find the memory issue any longer now.

F:\Files>java -Xms1024m -Xmx1024m MyTest

F:\Files>

Here is the JAVA program:

Sample code:

Workbook workbook = new Workbook(“31d54ba00a03000e00eb3071fea764d8_Sheet1.csv”);
workbook.getWorksheets().get(“Sheet1”).autoFitRows();

workbook.save(“31d54ba00a03000e00eb3071fea764d8_Sheet1.xlsx”);

The output file has 27MB size.

Thank you.