/** * Import a <CODE>Table</CODE> into the <CODE>RtfTable</CODE>. * <P> * @param table A <code>Table</code> specifying the <code>Table</code> to be imported * @param pageWidth An <code>int</code> specifying the page width * @return true if importing the table succeeded */ public bool ImportTable(Table table, int pageWidth) { origTable = table; // All Cells are pregenerated first, so that cell and rowspanning work int tableWidth = (int)table.WidthPercentage; int cellpadding = (int)(table.Cellpadding * RtfWriter.TWIPSFACTOR); int cellspacing = (int)(table.Cellspacing * RtfWriter.TWIPSFACTOR); float[] propWidths = table.ProportionalWidths; int borders = table.Border; Color borderColor = table.BorderColor; float borderWidth = table.BorderWidth; for (int j = 0; j < table.Size; j++) { RtfRow rtfRow = new RtfRow(writer, this); rtfRow.PregenerateRows(table.Columns); rowsList.Add(rtfRow); } int i = 0; foreach (Row row in table) { row.HorizontalAlignment = table.Alignment; RtfRow rtfRow = (RtfRow)rowsList[i]; rtfRow.ImportRow(row, propWidths, tableWidth, pageWidth, cellpadding, cellspacing, borders, borderColor, borderWidth, i); i++; } return(true); }
/** * Output the content of the <CODE>RtfTable</CODE> to an Stream. * * @param os The <code>Stream</code> that the content of the <code>RtfTable</code> is to be written to * @return true if writing the table succeeded * @throws DocumentException * @throws IOException */ public bool WriteTable(MemoryStream os) { if (!this.writer.WritingHeaderFooter()) { // Added by Benoit WIART <*****@*****.**> // Add a new line before each table os.WriteByte(RtfWriter.escape); os.Write(RtfWriter.paragraph, 0, RtfWriter.paragraph.Length); } int size = rowsList.Count; for (int i = 0; i < size; i++) { RtfRow row = (RtfRow)rowsList[i]; row.WriteRow(os, i, origTable); os.WriteByte((byte)'\n'); } if (!writer.WritingHeaderFooter()) { os.WriteByte(RtfWriter.escape); os.Write(RtfWriter.paragraphDefaults, 0, RtfWriter.paragraphDefaults.Length); os.WriteByte(RtfWriter.escape); os.Write(RtfWriter.paragraph, 0, RtfWriter.paragraph.Length); switch (origTable.Alignment) { case Element.ALIGN_LEFT: os.WriteByte(RtfWriter.escape); os.Write(RtfWriter.alignLeft, 0, RtfWriter.alignLeft.Length); break; case Element.ALIGN_RIGHT: os.WriteByte(RtfWriter.escape); os.Write(RtfWriter.alignRight, 0, RtfWriter.alignRight.Length); break; case Element.ALIGN_CENTER: os.WriteByte(RtfWriter.escape); os.Write(RtfWriter.alignCenter, 0, RtfWriter.alignCenter.Length); break; case Element.ALIGN_JUSTIFIED: case Element.ALIGN_JUSTIFIED_ALL: os.WriteByte(RtfWriter.escape); os.Write(RtfWriter.alignJustify, 0, RtfWriter.alignJustify.Length); break; } } return(true); }
/// <summary> /// Output the content of the RtfTable to an Stream. /// </summary> /// <param name="os">The Stream that the content of the RtfTable is to be written to</param> /// <returns></returns> public bool writeTable(MemoryStream os) { // <!-- steffen int size = rowsList.Count; for (int i = 0; i < size; i++) { RtfRow row = (RtfRow)rowsList[i]; row.writeRow(os, i, origTable); os.WriteByte((byte)'\n'); } // --> if (!writer.writingHeaderFooter()) { os.WriteByte(RtfWriter.escape); os.Write(RtfWriter.paragraphDefaults, 0, RtfWriter.paragraphDefaults.Length); os.WriteByte(RtfWriter.escape); os.Write(RtfWriter.paragraph, 0, RtfWriter.paragraph.Length); } return(true); }
/// <summary> /// Import a Table into the RtfTable. /// </summary> /// <param name="table">A Table specifying the Table to be imported</param> /// <param name="pageWidth">An int specifying the page width</param> /// <returns></returns> public bool importTable(Table table, int pageWidth) { // <!-- steffen origTable = table; // --> // All Cells are pregenerated first, so that cell and rowspanning work int tableWidth = (int)table.WidthPercentage; int cellpadding = (int)(table.Cellpadding * RtfWriter.twipsFactor); int cellspacing = (int)(table.Cellspacing * RtfWriter.twipsFactor); float[] propWidths = table.ProportionalWidths; int borders = table.Border; Color borderColor = table.BorderColor; float borderWidth = table.BorderWidth; for (int i = 0; i < table.Size; i++) { RtfRow rtfRow = new RtfRow(writer, this); rtfRow.pregenerateRows(table.Columns); rowsList.Add(rtfRow); } int j = 0; foreach (Row row in table) { RtfRow rtfRow = (RtfRow)rowsList[j]; // steffen // <--- rtfRow.importRow(row, propWidths, tableWidth, pageWidth, cellpadding, cellspacing, borders, borderColor, borderWidth, j); // --> j++; } return(true); }
/// <summary> /// RtfCells call this method to specify that a certain other cell is to be merged with it. /// </summary> /// <param name="x">The column position of the cell to be merged</param> /// <param name="y">The row position of the cell to be merged</param> /// <param name="mergeType">The merge type specifies the kind of merge to be applied (MERGE_HORIZ_PREV, MERGE_VERT_PREV, MERGE_BOTH_PREV)</param> /// <param name="mergeCell">The RtfCell that the cell at x and y is to be merged with</param> public void setMerge(int x, int y, int mergeType, RtfCell mergeCell) { RtfRow row = (RtfRow)rowsList[y]; row.setMerge(x, mergeType, mergeCell); }
/** * Import a <CODE>Table</CODE> into the <CODE>RtfTable</CODE>. * <P> * @param table A <code>Table</code> specifying the <code>Table</code> to be imported * @param pageWidth An <code>int</code> specifying the page width * @return true if importing the table succeeded */ public bool ImportTable(Table table, int pageWidth) { origTable = table; // All Cells are pregenerated first, so that cell and rowspanning work int tableWidth = (int) table.WidthPercentage; int cellpadding = (int) (table.Cellpadding * RtfWriter.TWIPSFACTOR); int cellspacing = (int) (table.Cellspacing * RtfWriter.TWIPSFACTOR); float[] propWidths = table.ProportionalWidths; int borders = table.Border; Color borderColor = table.BorderColor; float borderWidth = table.BorderWidth; for (int j = 0; j < table.Size; j++) { RtfRow rtfRow = new RtfRow(writer, this); rtfRow.PregenerateRows(table.Columns); rowsList.Add(rtfRow); } int i = 0; foreach (Row row in table) { row.HorizontalAlignment = table.Alignment; RtfRow rtfRow = (RtfRow) rowsList[i]; rtfRow.ImportRow(row, propWidths, tableWidth, pageWidth, cellpadding, cellspacing, borders, borderColor, borderWidth, i); i++; } return true; }