导出到excel,同时包含大量数据

问题描述:

当我导出具有大量数据(例如:100 行)的 excel 时,我在打开工作表时低于警报.如果我们点击继续,它会在受保护的视图中打开.

While I am exporting excel which has huge data(ex:100 rows) I am getting below alert while opening sheet. And if we click on proceed,it is opening in protected view.

当我们保存这个 excel 时,它会警告无法在受保护的视图中保存",如果我们继续,保存的 excel 表中的样式和字体设置将被更改.

While we save this excel it is alerting as "unable to save in protected view" and if we proceed the styles and font settings are altered in the excel sheet saved.

我该怎么做才能避免这种情况?

What can I do to avoid this?

  //u can call this style method before loops where we are creating cells
   HSSFCellStyle yellowStyle = getYellowColoreBasedOnNewField(workBook);     

  private HSSFCellStyle getYellowColoreBasedOnNewField(HSSFWorkbook workBook) {
    HSSFCellStyle style = workBook.createCellStyle();
    HSSFFont font = createAndSetFontStyle(workBook);
    setYellowColor(style, font);
    return style;
} 

    private HSSFFont createAndSetFontStyle(HSSFWorkbook wb) {
    HSSFFont font = wb.createFont();
    font.setFontName(XSSFFont.DEFAULT_FONT_NAME);
    font.setFontHeightInPoints((short)10);
    return font;
}