public void WriteMapItem(LayoutColumn map, int listIndex, object listItem, int sc, int sr, ref int mr, StringKeyList stringTable, List <Row> prows = null) { int tws = map.GetWithdSpan(); Row row = null; var rows = prows; if (prows == null) { rows = new List <Row>(); mr++; row = GenerateRow(mr, mc, listItem == null, stringTable); WriteCell(row.GetFirstChild <Cell>(), listItem == null ? (object)"#" : (object)(listIndex + 1), stringTable); rows.Add(row); sc = 1; } var nr = mr; foreach (var item in map) { if (item.Visible) { map.GetVisibleIndex(item, out int c, out int r); c += sc; r += sr; if (item.Count > 0) { WriteMapItem(item, listIndex, listItem, c, r, ref mr, stringTable, rows); } else { int rr = nr + r; if (rows.Count <= r) { mr++; row = GenerateRow(rr, mc, listItem == null, stringTable); rows.Add(row); } else { row = rows[r]; } object celldata = ((LayoutColumn)item).Text; if (listIndex == -2) { celldata = list.GetCollectedValue((LayoutColumn)item, group); } if (listItem != null) { object val = list.ReadValue(listItem, (ILayoutCell)item); celldata = list.FormatValue(listItem, val, (ILayoutCell)item); if (val is decimal && ((ILayoutCell)item).Format != "p") { celldata = val; } if (prows == null && c == 1 && listItem is Node) { var s = GroupHelper.Level((Node)listItem) * 4; celldata = celldata.ToString().PadLeft(celldata.ToString().Length + s, '-'); } } var cellc = (Cell)row.ChildElements.GetItem(c); WriteCell(cellc, celldata, stringTable); if (celldata is decimal) { cellc.StyleIndex = 3; } int ws = map.GetRowWidthSpan(item.Row); int hs = map.GetRowHeightSpan(item.Row, true); if (tws > ws && hs > 1) { mcells.Add(new MergeCell() { Reference = new CellRange(c, rr, c + tws - ws, rr + hs - 1).ToString() }); } else if (tws > ws) { mcells.Add(new MergeCell() { Reference = new CellRange(c, rr, c + tws - ws, rr).ToString() }); } else if (hs > 1) { mcells.Add(new MergeCell() { Reference = new CellRange(c, rr, c, rr + hs - 1).ToString() }); } } } } if (prows == null) { if (rows.Count > 1) { mcells.Add(new MergeCell() { Reference = new CellRange(0, nr, 0, nr + rows.Count - 1).ToString() }); } if (listItem is Node) { foreach (var item in rows) { item.OutlineLevel = (byte)(GroupHelper.Level((IGroup)listItem)); if (((IGroup)listItem).IsCompaund) { item.Collapsed = !((IGroup)listItem).Expand; } if (item.OutlineLevel > 0) { item.Hidden = !((IGroup)listItem).IsExpanded; } } } WriteRows(writer, rows); if (listItem is Node && map != null) { var i = 0; foreach (var item in ((Node)listItem).Nodes) { WriteMapItem(map, i++, item, 0, 0, ref mr, stringTable); } } } }
public void ExpMapLayout(Doc.Odf.Table sheetData, LayoutColumn map, int scol, int srow, out int mcol, out int mrow, LayoutList list, object listItem) { int tws = map.GetWithdSpan(); //int ths = tool.LayoutMapTool.GetHeightSpan(map); mrow = srow; mcol = scol; Doc.Odf.Row temp = null; for (int i = 0; i < map.Count; i++) { var item = map[i]; if (!item.Visible) { continue; } map.GetVisibleIndex(item, out int cc, out int rr); int c = cc + scol; int r = rr + srow; if (item.Count > 0) { ExpMapLayout(sheetData, item, c, r, out c, out r, list, listItem); } else { Doc.Odf.Cell cell = GetCell(sheetData, c, r); if (list != null) { cell.StyleName = "ce3"; cell.Val = list.FormatValue(listItem, (ILayoutCell)item) as string; } else { cell.StyleName = "ce1"; cell.Val = item.Text; GetColumn(sheetData, c + 1, item.Width); } if (temp == null || temp.Index != r) { temp = GetRow(sheetData, r, mrow >= r); } if (r > mrow && r > srow) { for (int j = 0; j < scol; j++) { var ccell = new Doc.Odf.CoveredCell(sheetData.Document); temp.Add(ccell); } } temp.Add(cell); int ws = map.GetRowWidthSpan(item.Row); if (tws > ws) { cell.NumberColumnsSpanned = ((tws - ws) + 1).ToString(); cell.NumberRowsSpanned = "1"; var ccell = new Doc.Odf.CoveredCell(sheetData.Document) { ColumnsRepeatedCount = (tws - ws).ToString() }; temp.Add(ccell); } int hs = map.GetRowHeightSpan(item.Row, true); if (hs > 1) { cell.NumberRowsSpanned = (hs).ToString(); if (cell.NumberColumnsSpanned.Length == 0) { cell.NumberColumnsSpanned = "1"; } } } if (r > mrow) { mrow = r; } if (c > mcol) { mcol = c; } } }
public void ExpMapLayout(SheetData sheetData, LayoutColumn map, int scol, int srow, out int mcol, out int mrow, LayoutList list, object listItem, StringKeyList stringTable) { int tws = map.GetWithdSpan(); //int ths = tool.LayoutMapTool.GetHeightSpan(map); mrow = srow; mcol = scol; Row temp = null; for (int i = 0; i < map.Count; i++) { var item = map[i]; if (!item.Visible) { continue; } map.GetVisibleIndex(item, out int c, out int r); c += scol; r += srow; if (item.Count > 0) { ExpMapLayout(sheetData, item, c, r, out c, out r, list, listItem, stringTable); } else { object celldata = ((LayoutColumn)item).Text; if (list != null) { object val = list.ReadValue(listItem, (ILayoutCell)item); celldata = list.FormatValue(listItem, val, (ILayoutCell)item); if (val is decimal && decimal.TryParse(celldata.ToString(), out decimal dval)) { celldata = val; } } Cell cell = GetCell(celldata, c, r, celldata is decimal ? 3U : 6U, stringTable); if (list == null) { cell.StyleIndex = 7; GetColumn(sheetData, c + 1, item.Width); } if (temp == null || temp.RowIndex != r) { temp = GetRow(sheetData, r, mrow >= r); } temp.Append(cell); int ws = map.GetRowWidthSpan(item.Row); if (tws > ws) { MergeCell mcell = new MergeCell() { Reference = new CellRange(c, r, c + tws - ws, r).ToString() }; GetMergeCells(sheetData.Parent).Append(mcell); } int hs = map.GetRowHeightSpan(item.Row, true); if (hs > 1) { MergeCell mcell = new MergeCell() { Reference = new CellRange(c, r, c, r + hs - 1).ToString() }; GetMergeCells(sheetData.Parent).Append(mcell); } } if (r > mrow) { mrow = r; } if (c > mcol) { mcol = c; } } }