2013年9月10日星期二

JAVA POI Export EXCEL template how to set the cell format to text

I'm not talking color background etc. Style

I want to achieve the effect of the input number " 0123456 " to save " 0123456 " instead of " 123456"

existing projects with - export EXCEL template - add numbers will be lost "0 ." ( Export data without problems, you can export the "0 " at the beginning of the number )

inside how to write in JAVA number column for the export template text format

Here is the header row of the exported file excel

public static void createColHeader (HSSFSheet sheet, CellStyle cellStyle, String [] columHeader) {
if (sheet! = null) {
sheet.setDefaultColumnWidth (20);
HSSFRow row = sheet.createRow (0);
for (int i = 0; i HSSFCell cell = row.createCell (i);
cell.setCellValue (columHeader [i]);
if (cellStyle! = null) {
cell.setCellStyle (cellStyle);
}
}
freezePane (sheet, 0,1,0,1);
}
}


------ Solution ------------------------------------ --------
EXCEL can put the column formatted as text on the line :
Select the row number , right : Format Cells - " 'Text ' can be.

------ Solution ------------------------------------ --------
cell.setCellType (HSSFCell.CELL_TYPE_STRING);
------ Solution -------------------- ------------------------
try the following command
cell.setCellType (HSSFCell.CELL_TYPE_STRING);
------ Solution --------------------------- -----------------
with csv export excel try
------ For reference only ------------ ---------------------------
=. = ! ! ! I mean to use JAVA how to achieve it ?

impossible to call each of them with a template to modify it again spreading. .
------ For reference only -------------------------------------- -
there is no significant know ah ~
------ For reference only ---------------------------- -----------
cell.setCellType (HSSFCell.CELL_TYPE_STRING)
just forgot to say, I tried , as always lost 0
------ For reference only ------------------- --------------------
own top up . . .
------ For reference only -------------------------------------- -
=. =! own roof . . .
------ For reference only -------------------------------------- -
not lost 0 ah , I 've tried it !
------ For reference only -------------------------------------- -
landlord resolve not ? Can teach about
------ For reference only ---------------------------------- -----
get no ah ?

没有评论:

发表评论