예제 #1
0
파일: StylesTable.cs 프로젝트: zbl960/npoi
 /**
  * Create a new, empty StylesTable
  */
 public StylesTable()
     : base()
 {
     doc = new StyleSheetDocument();
     doc.AddNewStyleSheet();
     // Initialization required in order to make the document Readable by MSExcel
     Initialize();
 }
예제 #2
0
 protected void ReadFrom(Stream is1)
 {
     try
     {
         this.doc = StyleSheetDocument.Parse(is1);
         CT_Stylesheet styleSheet = this.doc.GetStyleSheet();
         CT_NumFmts    numFmts    = styleSheet.numFmts;
         if (numFmts != null)
         {
             foreach (CT_NumFmt ctNumFmt in numFmts.numFmt)
             {
                 this.numberFormats.Add((int)ctNumFmt.numFmtId, ctNumFmt.formatCode);
             }
         }
         CT_Fonts fonts = styleSheet.fonts;
         if (fonts != null)
         {
             int index = 0;
             foreach (CT_Font font in fonts.font)
             {
                 this.fonts.Add(new XSSFFont(font, index));
                 ++index;
             }
         }
         CT_Fills fills = styleSheet.fills;
         if (fills != null)
         {
             foreach (CT_Fill Fill in fills.fill)
             {
                 this.fills.Add(new XSSFCellFill(Fill));
             }
         }
         CT_Borders borders = styleSheet.borders;
         if (borders != null)
         {
             foreach (CT_Border border in borders.border)
             {
                 this.borders.Add(new XSSFCellBorder(border));
             }
         }
         CT_CellXfs cellXfs = styleSheet.cellXfs;
         if (cellXfs != null)
         {
             this.xfs.AddRange((IEnumerable <CT_Xf>)cellXfs.xf);
         }
         CT_CellStyleXfs cellStyleXfs = styleSheet.cellStyleXfs;
         if (cellStyleXfs != null)
         {
             this.styleXfs.AddRange((IEnumerable <CT_Xf>)cellStyleXfs.xf);
         }
         CT_Dxfs dxfs = styleSheet.dxfs;
         if (dxfs == null)
         {
             return;
         }
         this.dxfs.AddRange((IEnumerable <CT_Dxf>)dxfs.dxf);
     }
     catch (XmlException ex)
     {
         throw new IOException(ex.Message);
     }
 }
예제 #3
0
파일: StylesTable.cs 프로젝트: zbl960/npoi
        /**
         * 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);
            }
        }
예제 #4
0
 public StylesTable()
 {
     this.doc = new StyleSheetDocument();
     this.doc.AddNewStyleSheet();
     this.Initialize();
 }