Hi Team,
My Aim is To Read the .Ods file. Create the text files as number of rows in the Ods file and Write the Data Row by Row into that Text File.
Attached Sample file for Reference.
In the attached file i Have 10 rows so ten Text file should be created and single row will be Written in the file.
Pleae Help me for doing this.
Thanks…
Hi,
Thanks for your interest in Aspose.Cells.
Yes, you can read ODS files easily using Aspose.Cells.
Please refer to this document to see how to open ods file: Opening Files
In this document, you will learn how to create a Workbook from your ODS file.
Once you have successfully opened your file and create a Workbook object, then you should refer to these documents to achieve your desired functionality.
Hi,
Here is some source code for your need. Cheers
JAVA
Workbook wb = new Workbook();
wb.open(“C:\temp\OUT.ods”);
Worksheet sheet = wb.getWorksheets().getSheet(0);
Cells cells = sheet.getCells();
for(int i=0; i<cells.getMaxDataRow();i++)
{
BufferedWriter out = new BufferedWriter(new FileWriter(“C:\temp\Row” + i + “.txt”));
String row = “”;
for(int j=0; j<cells.getMaxDataColumn();j++)
{
Object obj = cells.getRows().getRow(i).getCell(j).getValue();
if(obj!=null)
{
row += obj.toString().replace(“null”, “”);
row += " ";
}
}
out.write(row);
out.close();
}