Hello,
I am sorta new to Aspose.words and had couple small problems with the table formatting. What I would like to do are 1) make the text in each cell align to center. 2) expand the table so it will fit the page width, rather than squeezing in the middle of the page.
My code is listed below and sample output is attached. Thank you for your help.
300 builder.RowFormat.Alignment = RowAlignment.Center;
301 builder.RowFormat.AllowAutoFit = true;
304
305
306
307 //builder.Font.Bold = true;
308 builder.CellFormat.Shading.BackgroundPatternColor = System.Drawing.Color.SteelBlue;
309 builder.CellFormat.Borders.Color = System.Drawing.Color.White;
310 //builder.CellFormat.FitText = true;
311 builder.CellFormat.WrapText = false;
312 //builder.CellFormat.VerticalAlignment = CellVerticalAlignment.Center;
313 builder.CellFormat.Borders.LineWidth = 2;
314 builder.CellFormat.Orientation = TextOrientation.Horizontal;
315 builder.Font.Color = System.Drawing.Color.White;
316
317 builder.InsertCell();
318 builder.Write("Reference Number");
319 builder.InsertCell();
320 builder.Write("Product");
321 builder.InsertCell();
322 builder.Write("Expected OCI Reclass");
323 builder.InsertCell();
324 builder.Write("Reclass Start Date");
325 builder.InsertCell();
326 builder.Write("Reclass End Date");
327 builder.EndRow();
328
329 builder.Font.Bold = false;
330 builder.CellFormat.Shading.BackgroundPatternColor = System.Drawing.Color.MintCream;
331 builder.Font.Color = System.Drawing.Color.Black;
332
333 foreach (DataRow ociRow in dsOCI.Tables["OCIAmount"].Rows)
334 {
335 builder.InsertCell();
336 builder.Write(ociRow["tr_reference_nbr"].ToString());
337 builder.InsertCell();
338 builder.Write(ociRow["tq_dd_product"].ToString());
339 builder.InsertCell();
340 if (IsNumeric(ociRow["oci_reclass"]) == true)
341 {
342 builder.Write(String.Format("{0:#,##0;(#,##0)}", Decimal.Parse(ociRow["oci_reclass"].ToString())));
343 totalOCI = totalOCI + Decimal.Parse(ociRow["oci_reclass"].ToString());
344 }
345 else
346 {
347 builder.Write("N/A");
348 }
349 builder.InsertCell();
350 builder.Write(String.Format("{0: dd-MMM-yy}", DateTime.Parse(ociRow["FiscalYrEffTestStartDt"].ToString())));
351 builder.InsertCell();
352 builder.Write(String.Format("{0: dd-MMM-yy}", DateTime.Parse(ociRow["FiscalYrEffTestEndDt"].ToString())));
353 builder.EndRow();
354
355 }