public Table GetExcelTable(IWorksheet worksheet, Selection selection) { Table table = new Table(worksheet.Name, selection.ColumnCount, selection.RowCount); int rowOffset = selection.StartRow; int columnOffset = selection.StartColumn; for (int i = 0; i < selection.RowCount; i++) { for (int j = 0; j < selection.ColumnCount; j++) { var excelCell = worksheet.Cells[i + rowOffset, j + columnOffset]; table.Rows[i].Columns[j] = ExtractExcelCellProperty(excelCell); } } return table; }
public override string GetConvertedContent(Table excelTable) { ArgumentUtility.EnsureNotNull(excelTable, "excelTable"); StringBuilder str = new StringBuilder(); var isFirstRow = true; foreach (var row in excelTable.Rows) { foreach (var cell in row.Columns) { str.Append(string.Format("{0} {1} ", GetColumnSeparator(isFirstRow), PrepareCellValue(cell))); } str.AppendLine(GetColumnSeparator(isFirstRow)); isFirstRow = false; } return str.ToString(); }
public override string GetConvertedContent(Table table) { if (table != null && table.Rows.Count > 0) { StringBuilder returnValue = new StringBuilder(); returnValue.Append(AppendBeginTableEnvironmentIfSet()); returnValue.Append(AppendBeginTabular()); returnValue.Append(AppendColumnDefinitions(table.Rows[0])); returnValue.Append(CloseBeginTabular()); returnValue.Append(AppendHorizontalRuleIfSet(table.Rows[0], useBottomRuleFromRow: false, rowCount: 0, totalRows:table.Rows.Count)); returnValue.Append(AppendNewLine()); returnValue.Append(AppendTableContent(table, table.Rows[0])); returnValue.Append(AppendEndTabular()); returnValue.Append(AppendEndTableEnvironmentIfSet(table)); return returnValue.ToString(); } throw new ArgumentException("table is null"); }
private static Table GetSimpleTable() { int maxColumns = 5; int maxRows = 4; var table = new Table("simple table", maxColumns, maxRows); for (int i = 0; i < maxRows; i++) { for (int j = 0; j < maxColumns; j++) { table.Rows[i].Columns[j] = new Cell { Text = (i + 1).ToString() + " " + (j + 1).ToString(), TextEmphasis = new List<Cell.EmphasisEnum>(), TextColor = Color.Black, FillColor = Color.White, Borders = new Dictionary<Cell.BorderPositionEnum, BorderInformation>() }; } } return table; }
private string GetCaptionName(Table table) { return string.IsNullOrEmpty(_extendedFeatures.TableName) ? table.SheetName : _extendedFeatures.TableName; }
private string AppendTableContent(Table table, Row firstRow) { StringBuilder tableContent = new StringBuilder(); var rowCount = 0; foreach (var row in table.Rows) { tableContent.Append(AppendRow(row, firstRow, ++rowCount, table.Rows.Count)); } return tableContent.ToString(); }
private string AppendEndTableEnvironmentIfSet(Table table) { if (_extendedFeatures.AddTableEnvironment) { var tableEnvironment = AppendNewLine(); tableEnvironment += AppendCaption(table); tableEnvironment += AppendEndTable(); return tableEnvironment; } return string.Empty; }
private string AppendCaption(Table table) { return string.Format("\\caption{{{0}}}{1}", GetCaptionName(table), AppendNewLine()); }
public abstract string GetConvertedContent(Table excelTable);