Problem when Generate Report CSV

Stimulsoft Reports.NET discussion
Post Reply
ricardohtg
Posts: 3
Joined: Fri Nov 17, 2006 6:28 am
Location: brazil

Problem when Generate Report CSV

Post by ricardohtg »

Hi,

I need to generate report in CSV extension, but the title in report appears the textname and not the textvalue.

For example...

in report generate with CSV extension:
Text1 Text2 Text3 Text4
Carlos 3332565 São Paulo 12356

in report generate with XLS extension:
Name Phone City Adress Number
Carlos 3332565 São Paulo 12356
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Problem when Generate Report CSV

Post by Edward »

For CSV and DBF and XML export you should set the following in the Tag property of the StiText component:

Code: Select all

CSV: "ColumnHeader";DBF: "ColumnHeader";XML: "ColumnHeader"
Thank you.
ricardohtg
Posts: 3
Joined: Fri Nov 17, 2006 6:28 am
Location: brazil

Problem when Generate Report CSV

Post by ricardohtg »

Thank´s for resolve my problem.. ;)


Edward wrote:For CSV and DBF and XML export you should set the following in the Tag property of the StiText component:

Code: Select all

CSV: "ColumnHeader";DBF: "ColumnHeader";XML: "ColumnHeader"
Thank you.
Edward
Posts: 2913
Joined: Fri Jun 09, 2006 4:02 am

Problem when Generate Report CSV

Post by Edward »

Let me know if you need any help.

Thank you.
Colin Geis
Posts: 11
Joined: Thu Nov 12, 2009 3:55 pm
Location: Vancouver

Problem when Generate Report CSV

Post by Colin Geis »

I am having the same problem. That is, column headers are not showing in .CSV files.

Could you please give an example of the C# code needed to set the Tag propery?

Thank you.
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

Problem when Generate Report CSV

Post by Ivan »

Hello,

You can use following code, for example:

Code: Select all

            StiReport report = new StiReport();
            report.Load(@"D:\Report.mrt");

            StiText text1 = report.GetComponentByName("textBox1") as StiText;
            text1.Tag.Value = "CSV: \"ColumnHeaderName\";";

            report.Render();
            report.ExportDocument(StiExportFormat.Csv, @"d:\report.csv");

Thank you.
Colin Geis
Posts: 11
Joined: Thu Nov 12, 2009 3:55 pm
Location: Vancouver

Problem when Generate Report CSV

Post by Colin Geis »

Greetings!

Thank you very much.

The code example you gave to show column headers in .CSV files worked excellent using a band based solution (clarifying the use of double quotes within a string).

e.g.
StiHeaderBand headerBand = new StiHeaderBand();
StiText headerText = new StiText(new RectangleD(colStartPos, 0.5, colWidth, 0.5));
headerText.Text = colInfo.caption;
...
StiDataBand dataBand = new StiDataBand();
StiText dataText = new StiText(new RectangleD(colStartPos, 0, colWidth, 0.5));
dataText.Text = "{" + tableInfo.tableName + "." + colInfo.fieldName + "}";
...
string captionWithoutNewLine = colInfo.caption.Replace("\n", " ");
dataText.Tag.Value = "CSV: \"" + captionWithoutNewLine + "\";";
dataText.Tag.Value += "DBF: \"" + captionWithoutNewLine + "\";";
...
dataBand.Components.Add(dataText);

However, I am now using the same solution but with the new Table component...

e.g.
StiTable table = new StiTable();
table.Name = "Table1";
...
int indexHeaderCell = 0;
int indexDataCell = tableInfo.columnInfo.Count;
foreach (ColInformation colInfo in tableInfo.columnInfo)
{
StiTableCell headerCell = table.Components[indexHeaderCell] as StiTableCell;
headerCell.Text.Value = colInfo.caption;
...
StiTableCell dataCell = table.Components[indexDataCell] as StiTableCell;
dataCell.Text.Value = "{view" + tableInfo.tableName + "." + colInfo.fieldName + "}";
...
string captionWithoutNewLine = colInfo.caption.Replace("\n", " ");
dataCell.Tag.Value = "CSV: \"" + captionWithoutNewLine + "\";";
dataCell.Tag.Value += "DBF: \"" + captionWithoutNewLine + "\";";
...
indexHeaderCell++;
indexDataCell++;
}

with end result being column headers still not being displayed properly in .CSV files.

e.g.
Table1_Cell13 Table1_Cell14 Table1_Cell15 Table1_Cell16 Table1_Cell17
Roads Low C-Zone I3E 1322
C-Zone I3W 1301

In summary, I have the solution to show column headers in CSV files working with StiDataBand but not StiTable. So, if you could explain how to get column headers working for CSV files generated using StiTable it would be greatly appreciated.

Thank you in advance.
Ivan
Posts: 960
Joined: Thu Aug 10, 2006 1:37 am

Problem when Generate Report CSV

Post by Ivan »

Hello,

We made some improvements in that direction.
Please check the next prerelease build when it will be available and let us know about the result.

Thank you.
Post Reply