导出到excel,同时包含大量数据 [英] Export to excel while it contains huge data

查看:27
本文介绍了导出到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;
}

这篇关于导出到excel,同时包含大量数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆