Aspose formatting issues

Hello - I am trying to automate a document (see MNAOF attached) using Aspose by replacing bookmarks with content from C#. There are several issues with formatting as you can see in the second attachment (word2007)

  1. The bitmap graph is not very clear
  2. The pie-chart with legends become too small (can we mimic Excel pie chart as in the first attachment without any lines to the legends)
  3. the starttable()… insertcell() just default to non usuable widths. I need to autosize it to the max size of the content

Hi
Thanks for your request. Could you please reattach your first document? Also please provide me your code. To attach multiple files to one post you can archive them with zip or rar.
Best regards.

Hello for the chart - i create the chart (or graph) and use

mbuilder.insertimage(achart.getchartimage())

for table, i use

mbuilder.starttable()
foreach(datarow arow in atable.rows)
for(int j=0; j < atable.columns.count;j++){
mbuilder.insertcell();
mbuilder.write(arow[j].tostring());
}
    mbuilder.endrow();
}

Hi
Thanks for additional information.

  1. I can’t reproduce issue with cells width on my side. I used the following code for testing and it seems that all works fine.
Document doc = new Document(@"Test063\MNAOF.doc");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToDocumentEnd();
builder.StartTable();
foreach (DataRow arow in atable.Rows)
{
    for (int j = 0; j < atable.Columns.Count; j++)
    {
        builder.InsertCell();
        builder.Write(arow[j].ToString());
    }
    builder.EndRow();
}
builder.EndTable();
doc.Save(@"Test063\out.doc");

Maybe I should use some template document. If so please attach this document.
2. Please tell me how you get the chart pictures? Are you using Aspose.Cells? please attach sample images and if needed the excel workbook.

Best regards.

  1. The chart is created by aspose.chart
  2. I am using the same code as you. It looks as though because I am inserting a cell within an existing MSWord table cell that the format is not working at all.

Hi
Thank you for additional information.

  1. I think that I have found workaround for you. Please try using EMF picture format. For example try using the following simple code and you will see difference between images in the generated document.
// Create a sample chart.
Aspose.Chart.Chart lineChart = new Aspose.Chart.Chart();
lineChart.Height = 300;
lineChart.Width = 400;
Aspose.Chart.Series lineSeries = new Aspose.Chart.Series();
lineSeries.ChartType = Aspose.Chart.ChartType.Line;
lineSeries.Name = "Series";
lineSeries.DataPoints.Add(new Aspose.Chart.DataPoint(1, 1));
lineSeries.DataPoints.Add(new Aspose.Chart.DataPoint(2, 2));
lineSeries.DataPoints.Add(new Aspose.Chart.DataPoint(3, 3));
// Fill a series manually
lineChart.SeriesCollection.Add(lineSeries);
// Save chatr in EMF format
MemoryStream ms = new MemoryStream();
lineChart.Save(ms, ImageFormat.Emf);
// Create new document
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
// Insert chart using GetChartImage method
builder.InsertImage(lineChart.GetChartImage());
// Insert chart as EMF
builder.InsertImage(ms);
// Save document
doc.Save(@"Test068\out.doc");
  1. Maybe you can achieve this without using tables. Please see he attached document and the following code.
DataTable atable = new DataTable();
atable.Columns.Add("col1");
atable.Columns.Add("col2");
atable.Columns.Add("col3");
DataRow row = atable.NewRow();
row[0] = "US$2.53";
row[1] = "£1.27";
row[2] = "€1.70";
atable.Rows.Add(row);
Document doc = new Document(@"Test063\in.doc");
DocumentBuilder builder = new DocumentBuilder(doc);
// Move to cell
builder.MoveToCell(0, 0, 1, 0);
builder.Font.Color = Color.Black;
for (int j = 0; j < atable.Columns.Count; j++)
{
    // Insert value
    builder.Write(row[j].ToString());
    if (j != atable.Columns.Count - 1)
    {
        builder.Write(ControlChar.TabChar.ToString()); //Insert tab
    }
}
doc.Save(@"Test063\out.doc");

I hope this could help you.
Best regards.

Sorry - it doesn’t help. The whole thing is unsuable.

Hi

It is strange. I was sure that tip regarding EMF format should help you. See screenshot.
Maybe you can change your template that would not use nested tables.
Best regards.