Submitted Questions

  • Java code to set column width in CSV file

    Can someone help on how to set the column width in CSV file using javacode. I have used FileWriter class to upload data into the csv file. Results are getting populated properly but csv file showing results with default column width. Is there a way we can set the width of the column dynamically based on result length or set fixed length?

    Dusmanta

    • Nov 12th, 2014

    Use Apachae POI jar for this HSSFSheet sheet = workBook.createSheet("testXls");

    Code
    1. // Code to Auto size the column widths
    2.         for(int columnPosition = 0; columnPosition< 5; columnPosition++) {
    3.              sheet.autoSizeColumn((short) (columnPosition));
    4.         }