3

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.

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?

Gagravarr
  • 47,320
  • 10
  • 111
  • 156
swamy
  • 1,200
  • 10
  • 23
  • it has been resolved.As i applying styles for each cell individually and as creation of style sheets exceed more than the limit this problem is occuring. – swamy Jul 26 '12 at 10:47
  • if you have a found a solution, post it as an answer and accept your own answer. – gresdiplitude Jul 31 '12 at 05:02
  • i had created style sheets in the loop before.now i am creating styles out of the loop – swamy Jul 31 '12 at 11:00

1 Answers1

4
  //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;
}
swamy
  • 1,200
  • 10
  • 23
  • 2
    I think you missed the critical part of your example code where you actually assign the format to the cell. – Rory Feb 16 '16 at 23:55