I'm developing an application that generates an excel sheet with data collected from other files, for this I'm using jxl, the application is already generating the worksheet correctly, however I need to change some of the settings of these worksheets, such as the size of the column, I also need to place the entire worksheet in such a way that the information is displayed centrally. But the only thing I could change was the font style and background color, I did not find where I can make these other modifications. If you can help me, thank you.
Update
Code (with headers but columns not yet aligned):
if (arquivos != null) {
for (int x = 0; x < arquivos.length; x++) {
if (arquivos[x].getName().endsWith("pdf")) {
File f = arquivos[x];
try (RandomAccessBufferedFileInputStream acesso = new RandomAccessBufferedFileInputStream(f.getAbsolutePath())) {
PDFParser parser = new PDFParser(acesso);
parser.parse();
COSDocument cosDoc = parser.getDocument();
PDFTextStripper pdfStripper = new PDFTextStripper();
PDDocument pdDoc = new PDDocument(cosDoc);
WritableWorkbook planilha = Workbook.createWorkbook(new File(outPath + f.getName().replace(".pdf", ".xls"))); // Cria um arquivo XLS
WritableSheet aba = planilha.createSheet("Lote " + f.getName().replace(".pdf", ""), 0); // Nome da aba do arquivo XLS
String cabecalho[] = new String[4];
cabecalho[0] = "Página";
cabecalho[1] = "Autorização";
cabecalho[2] = "Status Leitura";
cabecalho[3] = "Retorno Ticket Log";
Colour bckcolor = Colour.DARK_BLUE; // Cor do fundo do cabeçalho
WritableCellFormat cellFormat = new WritableCellFormat();
cellFormat.setBackground(bckcolor);
cellFormat.setAlignment(Alignment.CENTRE);
WritableFont fonte = new WritableFont(WritableFont.ARIAL); // Formato da fonte do cabeçalho
fonte.setColour(Colour.WHITE); // Cor da fonte do cabeçalho
cellFormat.setFont(fonte);
WritableCellFormat cellFormat2 = new WritableCellFormat();
cellFormat2.setAlignment(Alignment.CENTRE);
for (int z = 0; z < cabecalho.length; z++) {
Label label = new Label(z, 0, cabecalho[z]);
aba.addCell(label);
WritableCell cell = aba.getWritableCell(z, 0);
cell.setCellFormat(cellFormat);
}
List<String> linhasGravadas = new ArrayList<>();
for (int i = 1; i <= pdDoc.getNumberOfPages(); i++) {
pdfStripper.setStartPage(i);
pdfStripper.setEndPage(i);
String parsedText = pdfStripper.getText(pdDoc);
String aut = "";
String Status = "";
String pagina = Integer.toString(i);
Label label = new Label(0, i, pagina);
aba.addCell(label);
label = new Label(1, i, aut);
aba.addCell(label);
label = new Label(2, i, Status);
aba.addCell(label);
}
planilha.write();
planilha.close();
acesso.close();
} catch (WriteException ex) {
Logger.getLogger(testeXML.class.getName()).log(Level.SEVERE, null, ex);
}
f.renameTo(new File(outPath , f.getName()));
}
}
}