Free Support Forum -

Workbook size

I’m using Aspose Cell for Java, is there a way to find out the size of the workbook object?



Thanks for your question and interest in Aspose.Cells.

You do not actually need Aspose.Cells for Java for this purpose. This could be done by other APIs provided by JDK 1.5.

You can search internet how to find the size of any file using Java API(s).

Please see this document, how to find file size in Java: Get file size


Much thanks for your reply.
What I’m trying to do is when generating workbook using aspose cell, if the workbook object reach to a pre-defined size, I’ll will write that workbook to csv file, then continue write data direct to csv file, instead of using aspose cell. I want to know the workbook object size before I write it to a file.



Thanks for clarification.

You should write your workbook object to stream, then you should get the size of the stream in bytes.

See the code below, how to save the workbook to stream. I used ByteArrayOutputStream object but you can use any.


//Save the workbook to stream
ByteArrayOutputStream stream= new ByteArrayOutputStream();, FileFormatType.DEFAULT);

//Get the stream size, which is the workbook size in bytes