private void GenerateTableSection(TableSection section, XmlWriter writer, DataTable dt, Padding padding, float height) { string sectionName = "", templateValue = "", value = ""; CellColors colors = null; switch (section) { case TableSection.Header: { sectionName = "Header"; templateValue = "{0}"; colors = new CellColors(Color.Black, Color.White); break; } case TableSection.Details: { sectionName = "Details"; templateValue = "=Fields!{0}.Value"; break; } case TableSection.Footer: { sectionName = "Footer"; templateValue = "{0}"; break; } } writer.WriteStartElement(sectionName); { if (section == TableSection.Header) { writer.WriteElementString("RepeatOnNewPage", "true"); } writer.WriteStartElement("TableRows"); { writer.WriteStartElement("TableRow"); { writer.WriteElementString("Height", height.ToString(ci) + "cm"); writer.WriteStartElement("TableCells"); { for (int i = 0; i < dt.Columns.Count; i++) { writer.WriteStartElement("TableCell"); { writer.WriteStartElement("ReportItems"); { value = String.Format(templateValue, dt.Columns[i].ColumnName); GenerateTextBox(writer, "textbox" + sectionName + i, RectangleF.Empty, padding, colors, value); } writer.WriteEndElement(); } writer.WriteEndElement(); } } writer.WriteEndElement(); } writer.WriteEndElement(); } writer.WriteEndElement(); } writer.WriteEndElement(); }
private void GenerateTextBox(XmlWriter writer, string textboxName, RectangleF dimensions, Padding padding, CellColors colors, string value) { writer.WriteStartElement("Textbox"); writer.WriteAttributeString("Name", textboxName); { writer.WriteElementString("rd", "DefaultName", nsRd, textboxName); if (dimensions != RectangleF.Empty) { writer.WriteElementString("Top", dimensions.Top.ToString(ci) + "cm"); writer.WriteElementString("Left", dimensions.Left.ToString(ci) + "cm"); writer.WriteElementString("Width", dimensions.Width.ToString(ci) + "cm"); writer.WriteElementString("Height", dimensions.Height.ToString(ci) + "cm"); } writer.WriteElementString("CanGrow", "true"); writer.WriteElementString("Value", value); if (padding != null) { writer.WriteStartElement("Style"); { writer.WriteStartElement("BorderStyle"); { writer.WriteElementString("Default", "Solid"); } writer.WriteEndElement(); if (colors != null) { writer.WriteElementString("Color", colors.ForegroundColor.Name); writer.WriteElementString("BackgroundColor", colors.BackgroundColor.Name); } writer.WriteElementString("PaddingLeft", padding.Left.ToString(ci) + "pt"); writer.WriteElementString("PaddingRight", padding.Right.ToString(ci) + "pt"); writer.WriteElementString("PaddingTop", padding.Top.ToString(ci) + "pt"); writer.WriteElementString("PaddingBottom", padding.Bottom.ToString(ci) + "pt"); } writer.WriteEndElement(); } } writer.WriteEndElement(); }