Write this table out as XML. @param out The stream to write to. @throws IOException if an error occurs while writing.
(OutputStream out)
| 337 | * @throws IOException if an error occurs while writing. |
| 338 | */ |
| 339 | public void writeTo(OutputStream out) throws IOException { |
| 340 | XmlOptions options = new XmlOptions(DEFAULT_XML_OPTIONS); |
| 341 | |
| 342 | // Work on the current one |
| 343 | // Need to do this, as we don't handle |
| 344 | // all the possible entries yet |
| 345 | CTStylesheet styleSheet = doc.getStyleSheet(); |
| 346 | |
| 347 | // Formats |
| 348 | CTNumFmts formats = CTNumFmts.Factory.newInstance(); |
| 349 | formats.setCount(numberFormats.size()); |
| 350 | for (Entry<Integer, String> fmt : numberFormats.entrySet()) { |
| 351 | CTNumFmt ctFmt = formats.addNewNumFmt(); |
| 352 | ctFmt.setNumFmtId(fmt.getKey()); |
| 353 | ctFmt.setFormatCode(fmt.getValue()); |
| 354 | } |
| 355 | styleSheet.setNumFmts(formats); |
| 356 | |
| 357 | int idx; |
| 358 | // Fonts |
| 359 | CTFonts ctFonts = CTFonts.Factory.newInstance(); |
| 360 | ctFonts.setCount(fonts.size()); |
| 361 | CTFont[] ctfnt = new CTFont[fonts.size()]; |
| 362 | idx = 0; |
| 363 | for(XSSFFont f : fonts) ctfnt[idx++] = f.getCTFont(); |
| 364 | ctFonts.setFontArray(ctfnt); |
| 365 | styleSheet.setFonts(ctFonts); |
| 366 | |
| 367 | // Fills |
| 368 | CTFills ctFills = CTFills.Factory.newInstance(); |
| 369 | ctFills.setCount(fills.size()); |
| 370 | CTFill[] ctf = new CTFill[fills.size()]; |
| 371 | idx = 0; |
| 372 | for(XSSFCellFill f : fills) ctf[idx++] = f.getCTFill(); |
| 373 | ctFills.setFillArray(ctf); |
| 374 | styleSheet.setFills(ctFills); |
| 375 | |
| 376 | // Borders |
| 377 | CTBorders ctBorders = CTBorders.Factory.newInstance(); |
| 378 | ctBorders.setCount(borders.size()); |
| 379 | CTBorder[] ctb = new CTBorder[borders.size()]; |
| 380 | idx = 0; |
| 381 | for(XSSFCellBorder b : borders) ctb[idx++] = b.getCTBorder(); |
| 382 | ctBorders.setBorderArray(ctb); |
| 383 | styleSheet.setBorders(ctBorders); |
| 384 | |
| 385 | // Xfs |
| 386 | if(xfs.size() > 0) { |
| 387 | CTCellXfs ctXfs = CTCellXfs.Factory.newInstance(); |
| 388 | ctXfs.setCount(xfs.size()); |
| 389 | ctXfs.setXfArray( |
| 390 | xfs.toArray(new CTXf[xfs.size()]) |
| 391 | ); |
| 392 | styleSheet.setCellXfs(ctXfs); |
| 393 | } |
| 394 | |
| 395 | // Style xfs |
| 396 | if(styleXfs.size() > 0) { |
no test coverage detected