how to use HSSFSheet to create an excel, with one row and two columns as shown in the figure?
3FA869B9-7071-4714-80A2-AC63734AD0BA.jpg
how to use HSSFSheet to create an excel, with one row and two columns as shown in the figure?
3FA869B9-7071-4714-80A2-AC63734AD0BA.jpg
try merging cells.
I don't know if the following code is what you want. It's part of the code that exports the tables of the database to excel's creation excel
.
//
HSSFRow titleRow = hssfSheet.createRow(0);
for(int i = 0 ; i < columnCount ; iPP){
HSSFCell headCell = titleRow.createCell(i);
headCell.setCellStyle(headCellStyle);
headCell.setCellValue(new HSSFRichTextString(columnNames.get(i)));
}
//
HSSFCellStyle bodyCellStyle = hssfWorkbook.createCellStyle();
HSSFFont bodyFont = hssfWorkbook.createFont();
bodyFont.setColor(Font.COLOR_NORMAL);
bodyFont.setBold(false);
bodyFont.setFontName("");
bodyFont.setFontHeight((short) 250);
bodyCellStyle.setFont(bodyFont);
//
try {
// excel
int columnRow = 1;
while(resultSet.next()){
HSSFRow bodyRow = hssfSheet.createRow(columnRowPP); //
for(int i = 0; i < columnCount; iPP){ //
HSSFCell bodyCell = bodyRow.createCell(i);
bodyCell.setCellStyle(bodyCellStyle);
bodyCell.setCellValue(new
HSSFRichTextString(resultSet.getString(columnNames.get(i))));
}
}
OutputStream writer = new FileOutputStream(path);
hssfWorkbook.write(writer);
} catch (SQLException e) {
isSuccess = false;
e.printStackTrace();
} catch (IOException e) {
isSuccess = false;
e.printStackTrace();
}
< H1 > question < H1 > poi reports an Duplicate PageSettingsBlock record exception when reading the xls file exported by the company s reporting system. org.apache.poi.hssf.record.RecordFormatException: Duplicate PageSettingsBlock record (sid=0x29) ...
when you use Java to read excel, the decimal is automatically converted to an imprecise decimal point. read the code of excel public static List<String[]> readExcel(File file) throws Exception { List<String[]> data...
suppose there is item number P1PowerP2and its price 10d20, the first column of the excel table generated by is a drop-down list, the median value of which is P1 or P2, select P1, the first row and the second column automatically populate the price 10 ...
how to extract pictures from excel files many packages can extract text information from excel files, but cannot extract pictures ...
timeout passed to the browser due to slow query speed or large amount of data because the default connection timeout for HTTP requests is 30 seconds, do you have any good methods? POI used by the development package ...