/** * Read this shared styles table from an XML file. * * @param is The input stream Containing the XML document. * @throws IOException if an error occurs while Reading. */ protected void ReadFrom(XmlDocument xmldoc) { try { doc = StyleSheetDocument.Parse(xmldoc, NamespaceManager); CT_Stylesheet styleSheet = doc.GetStyleSheet(); // Grab all the different bits we care about CT_NumFmts ctfmts = styleSheet.numFmts; if (ctfmts != null) { foreach (CT_NumFmt nfmt in ctfmts.numFmt) { numberFormats.Add((int)nfmt.numFmtId, nfmt.formatCode); } } CT_Fonts ctfonts = styleSheet.fonts; if (ctfonts != null) { int idx = 0; foreach (CT_Font font in ctfonts.font) { // Create the font and save it. Themes Table supplied later XSSFFont f = new XSSFFont(font, idx); fonts.Add(f); idx++; } } CT_Fills ctFills = styleSheet.fills; if (ctFills != null) { foreach (CT_Fill fill in ctFills.fill) { fills.Add(new XSSFCellFill(fill)); } } CT_Borders ctborders = styleSheet.borders; if (ctborders != null) { foreach (CT_Border border in ctborders.border) { borders.Add(new XSSFCellBorder(border)); } } CT_CellXfs cellXfs = styleSheet.cellXfs; if (cellXfs != null) { xfs.AddRange(cellXfs.xf); } CT_CellStyleXfs cellStyleXfs = styleSheet.cellStyleXfs; if (cellStyleXfs != null) { styleXfs.AddRange(cellStyleXfs.xf); } CT_Dxfs styleDxfs = styleSheet.dxfs; if (styleDxfs != null) { dxfs.AddRange(styleDxfs.dxf); } } catch (XmlException e) { throw new IOException(e.Message); } }
/** * For unit testing only! */ internal CT_Stylesheet GetCTStylesheet() { return(doc.GetStyleSheet()); }
/** * For unit testing only! */ public CT_Stylesheet GetCTStylesheet() { return(doc.GetStyleSheet()); }