How to convert xlsx file to csv?
<p>Currently I am using below code to convert XLSX file to CSV using Java. I need a faster solution because this is too slow.</p>
<pre><code>public class Test1 {
    static void convert(File inputFile, File outputFile) {
        try {
            FileOutputStream fos = new FileOutputStream(outputFile);
            // Get the workbook object for XLSX file
            XSSFWorkbook wBook = new XSSFWorkbook(
                    new FileInputStream(inputFile));
            // Get first sheet from the workbook
            XSSFSheet sheet = wBook.getSheetAt(0);
            Row row;
            Cell cell;
            // Iterate through each rows from first sheet
            Iterator&lt;Row&gt; rowIterator = sheet.iterator();

            while (rowIterator.hasNext()) {
                row = rowIterator.next();

                // For each row, iterate through each columns
                Iterator&lt;Cell&gt; cellIterator = row.cellIterator();
                while (cellIterator.hasNext()) {

                    cell = cellIterator.next();

                    switch (cell.getCellType()) {
                    case Cell.CELL_TYPE_BOOLEAN:
                        data.append(cell.getBooleanCellValue() + &quot;,&quot;);

                        break;
                    case Cell.CELL_TYPE_NUMERIC:
                        data.append(cell.getNumericCellValue() + &quot;,&quot;);

                        break;
                    case Cell.CELL_TYPE_STRING:
                        data.append(cell.getStringCellValue() + &quot;,&quot;);
                        break;

                    case Cell.CELL_TYPE_BLANK:
                        data.append(&quot;&quot; + &quot;,&quot;);
                        break;
                    default:
                        data.append(cell + &quot;,&quot;);

                    }
                }
            }

            fos.write(data.toString().getBytes());
            fos.close();

        } catch (Exception ioe) {
            ioe.printStackTrace();
        }
    }

    // testing the application

    public static void main(String[] args) {
        // reading file from desktop
        File inputFile = new File(&quot;D:\\Test.xlsx&quot;);
        // writing excel data to csv
        File outputFile = new File(&quot;D:\\Test1.csv&quot;);
        convert(inputFile, outputFile);
    }
}
</code></pre>