i want to know how can i set an alignment for cell in jxl library , it's default alignment is bottom and when i set alignment for WritableCellFormat
it throws me this Exception :
jxl.write.biff.JxlWriteException: Attempt to modify a referenced format
i set alignment this way :
WritableFont tahomaboldpt = new WritableFont(WritableFont.TAHOMA, 10,WritableFont.BOLD);
tahomaBold = new WritableCellFormat(tahomaboldpt);
tahomaBold.setAlignment(Alignment.CENTRE);
this throws me Exception in third line.Thanks in Advance
You need to create a WritableCellFormat object and pass this as an argument, when you want to create or add a cell in spreadsheet with the specified format.
Step 1: you can read the format from another cell (just like the below code or create a new one on your own) and then create a WritableCellFormat Object[newFormat object in below code]
Step 2: Add all the formatting you want example background , border, alignment etc as shown in the below code.
Step 3: when you create a new cell(or add a cell with particular format in excel), add the format as a parameter. newFormat(WritableCellFormat objecT) will the new format which you want to set.
Imports required for the above operation.