I am importing a csv file into an existing table in an Excel sheet and sometimes I want the headers to be visible and sometimes not. Whenever I choose to not show headers all text in my table becomes bold. Is there a way I can prevent this?
Attached is my Excel file with the table I am importing data into, the .csv file that is being imported and two PDFs that shows the reuslt with and without showing the header line.
I am using Aspose Cells Java 18.10
This is my code
License cellsLicense = new License();
cellsLicense.setLicense(“Aspose.Total.Java.lic”);
File csvFile = new File("data.csv");
List<String> csvData = Files.readAllLines(csvFile.toPath());
int noOfColumns = 7; //StringUtils.countMatches(csvData.get(0), ",");
Workbook workbook = createWorkbookFromTemplate();
Worksheet sheet = workbook.getWorksheets().get(0);
TxtLoadOptions options = new TxtLoadOptions();
options.setLanguageCode(CountryCode.USA);
Cells cells = sheet.getCells();
cells.importCSV(csvFile.getAbsolutePath(), options , 1, 0);
boolean hasHeaders = false; // Change to true for showing headers
ListObject listObject = sheet.getListObjects().get(0);
listObject.resize(0, 0, csvData.size() , noOfColumns, hasHeaders);
listObject.setShowHeaderRow(hasHeaders);
workbook.save(new File("generatedFile.pdf").getAbsolutePath());
AsposeBoldTextReport.zip (95.6 KB)
Thanks
Rickard