Exemplo n.º 1
0
 public SpreadsheetWorksheet(string name)
 {
     Name            = name;
     DrawingsManager = new DrawingsManager();
 }
Exemplo n.º 2
0
        private void writeSheetData(OpenXmlWriter writer, SpreadsheetStylesManager stylesManager, SpreadsheetHyperlinkManager hyperlinkManager, DrawingsManager drawingsManager)
        {
            writer.WriteStartElement(new SheetData());

            foreach (var row in _rows)
            {
                row.Value.WriteRow(writer, row.Key.ColumnIndex, row.Key.RowIndex, stylesManager, hyperlinkManager, drawingsManager);
            }

            foreach (var table in _tables)
            {
                if (!table.Value.IsInStreamingMode)
                {
                    continue;
                }

                using (var enumerator = table.Value.GetStreamingEnumerator())
                {
                    var tableRowPosition = table.Value.StreamedRowsSoFar;
                    while (enumerator.MoveNext())
                    {
                        var row = enumerator.Current;
                        row.WriteRow(writer, table.Key.ColumnIndex, table.Key.RowIndex + tableRowPosition + 1,
                                     stylesManager, hyperlinkManager, drawingsManager);
                        tableRowPosition++;
                    }
                }
            }

            writer.WriteEndElement();
        }
Exemplo n.º 3
0
        public void WriteRow(OpenXmlWriter writer, int columnIndex, int rowIndex, SpreadsheetStylesManager stylesManager, SpreadsheetHyperlinkManager hyperlinkManager, DrawingsManager drawingsManager)
        {
            var span          = string.Format("{0}:{1}", columnIndex, RowCells.Count + columnIndex);
            var attributeList = new List <OpenXmlAttribute>();

            var rowIndexAtt = new OpenXmlAttribute("r", null, rowIndex.ToString());
            var spanAtt     = new OpenXmlAttribute("spans", null, span);

            attributeList.Add(rowIndexAtt);
            attributeList.Add(spanAtt);
            if (this.RowHeight != null)
            {
                attributeList.Add(new OpenXmlAttribute("customHeight", null, "1"));
                attributeList.Add(new OpenXmlAttribute("ht", null, this.RowHeight.Value.ToString(CultureInfo.InvariantCulture)));
            }
            if (!IsVisible)
            {
                var hiddenAttribute = new OpenXmlAttribute("hidden", null, 1.ToString());
                attributeList.Add(hiddenAttribute);
            }
            if (!IsExpanded)
            {
                var hiddenAttribute = new OpenXmlAttribute("collapsed", null, 1.ToString());
                attributeList.Add(hiddenAttribute);
            }
            if (!IsMaster)
            {
                var hiddenAttribute = new OpenXmlAttribute("outlineLevel", null, 1.ToString());
                attributeList.Add(hiddenAttribute);
            }

            writer.WriteStartElement(new Row(), attributeList);
            foreach (var cell in RowCells)
            {
                if (cell.ImageIndex != -1)
                {
                    drawingsManager.SetImageForCell(new ImageDetails()
                    {
                        Column           = columnIndex,
                        ImageIndex       = cell.ImageIndex,
                        ImageScaleFactor = cell.ImageScaleFactor,
                        Indent           = cell.Indent,
                        Row = rowIndex
                    });
                }

                cell.WriteCell(writer, columnIndex, rowIndex, stylesManager, hyperlinkManager);
                columnIndex++;
            }
            writer.WriteEndElement();
        }