Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
JSpreadsheet
>
Tutorial
> Display Cell Values - Solution II
The following example shows you how to display values from all cells.
import com.independentsoft.office.spreadsheet.Workbook; import com.independentsoft.office.spreadsheet.Worksheet; public class Example { public static void main(String[] args) { try { Workbook book = new Workbook("c:\\test\\input.xlsx"); for(int i=0; i < book.getSheets().size(); i++) { if (book.getSheets().get(i) instanceof Worksheet) { Worksheet worksheet = (Worksheet)book.getSheets().get(i); System.out.println("Worksheet = " + worksheet.getName()); System.out.println("__________________________________"); for (int j = 0; j < worksheet.getRows().size(); j++) { if (worksheet.getRows().get(j) != null) { System.out.println(); //write row in new line for (int k = 0; k < worksheet.getRows().get(j).getCells().size(); k++) { if (worksheet.getRows().get(j).getCells().get(k) != null) { System.out.print(worksheet.getRows().get(j).getCells().get(k).getValue()); System.out.print("\t"); } } } } } } } catch (Exception e) { System.out.println(e.getMessage()); e.printStackTrace(); } } }
Need help? Ask our developers:
Name*
Email*
Message*