User Guide Tutorials J#.NET tutorials Tutorial 30: How to export data to CSV file in J#.NET |
|
How to export data to CSV file in J#.NET |
| | |
package Tutorial30;
import System.*;
import EasyXLS.*;
import EasyXLS.Constants.*;
public class Tutorial30
{
public Tutorial30()
{
}
public static void main(String[] args)
{
Console.WriteLine("Tutorial 30\n----------\n");
ExcelDocument workbook = new ExcelDocument(2);
workbook.easy_getSheetAt(0).setSheetName("First tab");
ExcelTable xlsFirstTable = ((ExcelWorksheet)workbook.easy_getSheetAt(0)).easy_getExcelTable();
for (int column=0; column<5; column++)
{
xlsFirstTable.easy_getCell(0,column).setValue("Column " + (column + 1));
xlsFirstTable.easy_getCell(0,column).setDataType(DataType.STRING);
}
for (int row=0; row<100; row++)
{
for (int column=0; column<5; column++)
{
xlsFirstTable.easy_getCell(row+1,column).setValue("Data " + (row + 1) + ", " + (column + 1));
xlsFirstTable.easy_getCell(row+1,column).setDataType(DataType.STRING);
}
}
Console.WriteLine("Writing file C:\\Samples\\Tutorial30 - export CSV file.csv.");
workbook.easy_WriteCSVFile("C:\\Samples\\Tutorial30 - export CSV file.csv", "First tab");
String sError = workbook.easy_getError();
if (sError.Equals(""))
Console.Write("\nFile successfully created. Press Enter to Exit...");
else
Console.Write("\nError encountered: " + sError + "\nPress Enter to Exit...");
workbook.Dispose();
Console.ReadLine();
}
}
|
|
|
|
|
|