private void ReadStyles(Stream xmlFileStream)
        {
            if (null == xmlFileStream) return;

            _Styles = new XlsxStyles();

            var rXlsxNumFmt = false;

            using (var reader = XmlReader.Create(xmlFileStream))
            {
                while (reader.Read())
                {
                    if (!rXlsxNumFmt && reader.NodeType == XmlNodeType.Element && reader.Name == N_numFmts)
                    {
                        while (reader.Read())
                        {
                            if (reader.NodeType == XmlNodeType.Element && reader.Depth == 1) break;

                            if (reader.NodeType == XmlNodeType.Element && reader.Name == XlsxNumFmt.N_numFmt)
                            {
                                _Styles.NumFmts.Add(
                                    new XlsxNumFmt(
                                        int.Parse(reader.GetAttribute(XlsxNumFmt.A_numFmtId)),
                                        reader.GetAttribute(XlsxNumFmt.A_formatCode)
                                        ));
                            }
                        }

                        rXlsxNumFmt = true;
                    }

                    if (reader.NodeType == XmlNodeType.Element && reader.Name == N_cellXfs)
                    {
                        while (reader.Read())
                        {
                            if (reader.NodeType == XmlNodeType.Element && reader.Depth == 1) break;

                            if (reader.NodeType == XmlNodeType.Element && reader.Name == XlsxXf.N_xf)
                            {
                                _Styles.CellXfs.Add(
                                    new XlsxXf(
                                        int.Parse(reader.GetAttribute(XlsxXf.A_xfId)),
                                        int.Parse(reader.GetAttribute(XlsxXf.A_numFmtId)),
                                        reader.GetAttribute(XlsxXf.A_applyNumberFormat)
                                        ));
                            }
                        }

                        break;
                    }
                }

                xmlFileStream.Close();
            }
        }
Beispiel #2
0
        private void ReadStyles(Stream xmlFileStream)
        {
            if (null == xmlFileStream)
            {
                return;
            }

            _Styles = new XlsxStyles();

            var rXlsxNumFmt = false;

            using (var reader = XmlReader.Create(xmlFileStream))
            {
                while (reader.Read())
                {
                    if (!rXlsxNumFmt && reader.NodeType == XmlNodeType.Element && reader.Name == N_numFmts)
                    {
                        while (reader.Read())
                        {
                            if (reader.NodeType == XmlNodeType.Element && reader.Depth == 1)
                            {
                                break;
                            }

                            if (reader.NodeType == XmlNodeType.Element && reader.Name == XlsxNumFmt.N_numFmt)
                            {
                                _Styles.NumFmts.Add(
                                    new XlsxNumFmt(
                                        int.Parse(reader.GetAttribute(XlsxNumFmt.A_numFmtId)),
                                        reader.GetAttribute(XlsxNumFmt.A_formatCode)
                                        ));
                            }
                        }

                        rXlsxNumFmt = true;
                    }

                    if (reader.NodeType == XmlNodeType.Element && reader.Name == N_cellXfs)
                    {
                        while (reader.Read())
                        {
                            if (reader.NodeType == XmlNodeType.Element && reader.Depth == 1)
                            {
                                break;
                            }

                            if (reader.NodeType == XmlNodeType.Element && reader.Name == XlsxXf.N_xf)
                            {
                                _Styles.CellXfs.Add(
                                    new XlsxXf(
                                        int.Parse(reader.GetAttribute(XlsxXf.A_xfId)),
                                        int.Parse(reader.GetAttribute(XlsxXf.A_numFmtId)),
                                        reader.GetAttribute(XlsxXf.A_applyNumberFormat)
                                        ));
                            }
                        }

                        break;
                    }
                }

                xmlFileStream.Close();
            }
        }