Package org.apache.poi.hssf.usermodel
Class HSSFOptimiser
- java.lang.Object
-
- org.apache.poi.hssf.usermodel.HSSFOptimiser
-
public class HSSFOptimiser extends java.lang.Object
Excel can get cranky if you give it files containing too many (especially duplicate) objects, and this class can help to avoid those. In general, it's much better to make sure you don't duplicate the objects in your code, as this is likely to be much faster than creating lots and lots of excel objects+records, only to optimise them down to many fewer at a later stage. However, sometimes this is too hard / tricky to do, which is where the use of this class comes in.
-
-
Constructor Summary
Constructors Constructor Description HSSFOptimiser()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
optimiseCellStyles(HSSFWorkbook workbook)
Goes through the Wokrbook, optimising the cell styles by removing duplicate ones, and ones that aren't used.static void
optimiseFonts(HSSFWorkbook workbook)
Goes through the Workbook, optimising the fonts by removing duplicate ones.
-
-
-
Method Detail
-
optimiseFonts
public static void optimiseFonts(HSSFWorkbook workbook)
Goes through the Workbook, optimising the fonts by removing duplicate ones. For now, only works on fonts used inHSSFCellStyle
andHSSFRichTextString
. Any other font uses (eg charts, pictures) may well end up broken! This can be a slow operation, especially if you have lots of cells, cell styles or rich text strings- Parameters:
workbook
- The workbook in which to optimise the fonts
-
optimiseCellStyles
public static void optimiseCellStyles(HSSFWorkbook workbook)
Goes through the Wokrbook, optimising the cell styles by removing duplicate ones, and ones that aren't used. For best results, optimise the fonts via a call tooptimiseFonts(HSSFWorkbook)
first.- Parameters:
workbook
- The workbook in which to optimise the cell styles
-
-