Esempio n. 1
0
 private void WriteWorkSheet_cols_Col(XElement colNode, Column col, WorkSheet sheet)
 {
     if (col.Width != sheet.DefaultColumnWidth && col.Width != ExcelCommon.WorkSheet_DefaultColumnWidth)
     {
         colNode.Add(new XAttribute(XName.Get("width"), col.Width));
         colNode.Add(new XAttribute(XName.Get("customWidth"), 1));
     }
     if (col.BestFit)
     {
         colNode.Add(new XAttribute(XName.Get("bestFit"), 1));
     }
     if (col.Collapsed)
     {
         colNode.Add(new XAttribute(XName.Get("collapsed"), 1));
     }
     if (col.Style != null)
     {
         colNode.Add(new XAttribute(XName.Get("style"), GetStyleId(col.Style)));
     }
     if (col.Phonetic)
     {
         colNode.Add(new XAttribute(XName.Get("phonetic"), 1));
     }
     if (col.OutlineLevel != 0)
     {
         colNode.Add(new XAttribute(XName.Get("outlineLevel"), col.OutlineLevel));
     }
     if (col.Hidden)
     {
         colNode.Add(new XAttribute(XName.Get("hidden"), 1));
     }
 }
Esempio n. 2
0
 private void WriteWorkSheet_cols_col_ColumnMax(ref int ColumnMax, Column col, XElement colNode)
 {
     if (col.ColumnMax > col.Index)
     {
         ColumnMax = col.ColumnMax;
         colNode.Add(new XAttribute(XName.Get("max"), col.ColumnMax));
     }
     else
         colNode.Add(new XAttribute(XName.Get("max"), col.Index));
 }
Esempio n. 3
0
 public Cell(Row row, Column column)
 {
     this.Column = column;
     this.Row = row;
 }
Esempio n. 4
0
 internal static Cell CreateNewCell(Row row, Column column)
 {
     return new Cell(row, column);
 }
Esempio n. 5
0
        /// <summary>
        /// FileName:sheet1.xml
        /// <para>NodePath:worksheet/sheetData/row/c</para>
        /// </summary>
        /// <param name="bookViewsRoot"></param>
        internal Cell ReadWorkSheet_sheetData_row_c(WorkSheet target, XElement item)
        {
            int rowIndex, columnIndex;
            ExcelHelper.GetRowCol(item.Attribute("r").Value, out rowIndex, out columnIndex, true);

            Row row = null;
            Column col = null;

            if (target.Rows.ContainsKey(rowIndex))
            {
                row = target.Rows[rowIndex];
            }
            else
            {
                row = new Row(rowIndex);
                target.Rows.Add(row);
            }

            if (target.Columns.ContainsKey(columnIndex))
            {
                col = target.Columns[columnIndex];
            }
            else
            {
                col = new Column(columnIndex);
                target.Columns.Add(col);
            }

            Cell cell = new Cell(row, col);
            if (item.Attribute("t") != null)
            {
                cell.DataType = item.Attribute("t").Value;
            }
            if (item.Attribute("s") == null)
            {
                cell.StyleID = 0;
                cell.Style = this.Context.GlobalStyles.CellStyleXfs[0];
            }
            else
            {
                cell.StyleID = int.Parse(item.Attribute("s").Value);
                cell.Style = this.Context.GlobalStyles.CellXfs[cell.StyleID];
            }

            return cell;
        }
Esempio n. 6
0
        /// <summary>
        /// FileName:sheet1.xml
        /// <para>NodePath:worksheet/cols/</para>
        /// </summary>
        /// <param name="bookViewsRoot"></param>
        internal void ReadWorkSheet_cols(WorkSheet target, XElement item)
        {
            foreach (XElement node in item.Nodes())
            {
                int min = int.Parse(node.Attribute("min").Value);
                int max = int.Parse(node.Attribute("max").Value);
                Column col = new Column(min);
                col.ColumnMax = max;
                int style = 0;
                if (node.Attribute("style") != null)
                {
                    if (int.TryParse(node.Attribute("style").Value, out style))
                    {
                        col.StyleID = style;
                        col.Style = this.Context.GlobalStyles.CellXfs[style];
                    }
                }

                col.Width = node.Attribute("width") == null ? 0 : double.Parse(node.Attribute("width").Value, CultureInfo.InvariantCulture);
                col.BestFit = node.Attribute("bestFit") != null && node.Attribute("bestFit").Value == "1" ? true : false;
                col.Collapsed = node.Attribute("collapsed") != null && node.Attribute("collapsed").Value == "1" ? true : false;
                col.Phonetic = node.Attribute("phonetic") != null && node.Attribute("phonetic").Value == "1" ? true : false;
                col.OutlineLevel = node.Attribute("outlineLevel") == null ? 0 : int.Parse(node.Attribute("outlineLevel").Value, CultureInfo.InvariantCulture);
                col.Hidden = node.Attribute("hidden") != null && node.Attribute("hidden").Value == "1" ? true : false;
                target.Columns.Add(col);
                if (max > min)
                {
                    for (int i = min + 1; i <= max; i++)
                    {
                        target.Columns.Add(col.Clone(i));
                    }
                }
            }
        }