1

I have an excel file with 1000's of rows and I want read each row at a time in Java using aspose API's. I want to convert each row into a String array. Can anyone help me with this?

Worksheet worksheet = workbook.getWorksheets().get(0);
Cells cells = worksheet.getCells();
nhgrif
  • 61,578
  • 25
  • 134
  • 173
user3566201
  • 47
  • 1
  • 7

2 Answers2

0

Aspose.Cells provides the LightCells API, mainly designed to read/ write cell's data one by one without building a complete data model block (using the Cell collection etc.) into memory. It works in an event-driven mode. I think you may try it. When reading template files, the component parses every cell and provides their value one by one. Please see the document for your reference here.

I am developer evangelist at Aspose.

Amjad Sahi
  • 1,813
  • 1
  • 10
  • 15
0
Cells cells = worksheet.getCells();
Range range = cells.getMaxDisplayRange();
int totalColumns = range.getColumnCount();
int totalRows = range.getRowCount();
RowCollection rows = cells.getRows();

for (int i = 1; i < rows.getCount(); i++) {
    for (int j = 0; j < totalColumns; j++) {
        System.out.print(cells.get(i, j).getValue() + "\t");
    }
    System.out.println("");
}
  • Welcome to Stack Overflow! Whilst this code snippet is welcome, and may provide some help, it would be [greatly improved if it included an explanation](//meta.stackexchange.com/q/114762) of *how* and *why* this solves the problem. Remember that you are answering the question for readers in the future, not just the person asking now! Please [edit] your answer to add explanation, and give an indication of what limitations and assumptions apply. – Toby Speight Apr 03 '17 at 12:57