export to csv options
export to csv options
I am trying to figure out how to configure my export to csv.
In the first place, I need to know how to how to pre-fill the export dialog options, most notably the file encoding and the separator. I can think of about 3 ways to do this, but I can't seem to find a way in any of them (at the view, at the viewer load snapshot callback, or at the export callback-thought this fires AFTER the dialog)
In the second place, how can I override the column headers?
In the first place, I need to know how to how to pre-fill the export dialog options, most notably the file encoding and the separator. I can think of about 3 ways to do this, but I can't seem to find a way in any of them (at the view, at the viewer load snapshot callback, or at the export callback-thought this fires AFTER the dialog)
In the second place, how can I override the column headers?
Re: export to csv options
in the user manual, I found section 5.8.1.1, which seems to address question #2, but I don't have a clue how to implement that in my code....
Re: export to csv options
in the 'programming manual' I found section 19.7.1.1 .... I'm confused on two counts. first, how to implement (as per my initial post), and second in regard to default values....I am skeptical that my default setting is Cyrillic, which is what comes up, but the document says it should be utf8.
Re: export to csv options
Hello.
You could set all export settings in code if you will export reports in code too.
We made a improvement and the default encoding in the Web Viewer will be UTF-8.
Thank you.
You should set the Tag property of the Text components on the Data Band and then the header in the csv file will be as you need.brianj774 wrote:in the user manual, I found section 5.8.1.1, which seems to address question #2, but I don't have a clue how to implement that in my code....
You could set all export settings in code if you will export reports in code too.
We made a improvement and the default encoding in the Web Viewer will be UTF-8.
Thank you.
Re: export to csv options
What I'm trying to do is to change the default settings for the dialog that pops up when a use selects save | Data | CSV File...
When the dialog opens, it shows page range gouping, and a settings grouping. Right now, the encoding defaults to Cyrillic for us, and we need this to be ASCII (UTF-8 may also be okay). The Separator option is set to ( ; ) semicolon, and needs to be ( , ) comma.
But, I would also accept a way to supress the ExportSettings dialog, and just manage the export entirely from code....I've found a way to do that "ShowExportDialog" and set to false, but I don't see how to then differentiate between all the different other export types. What I really want, is to just supress the CSV export dialog, and then to set the properties by hand as needed.
Please walk me thorough exactly what needs to be done to resolve this issue.
When the dialog opens, it shows page range gouping, and a settings grouping. Right now, the encoding defaults to Cyrillic for us, and we need this to be ASCII (UTF-8 may also be okay). The Separator option is set to ( ; ) semicolon, and needs to be ( , ) comma.
But, I would also accept a way to supress the ExportSettings dialog, and just manage the export entirely from code....I've found a way to do that "ShowExportDialog" and set to false, but I don't see how to then differentiate between all the different other export types. What I really want, is to just supress the CSV export dialog, and then to set the properties by hand as needed.
Please walk me thorough exactly what needs to be done to resolve this issue.
Re: export to csv options
Hello.
Here is a sample code how to export report to Csv:
The sample of using Tag property is in the attached report template. Please, look at the Tag property of the text components on the Band.
Thank you.
Here is a sample code how to export report to Csv:
Code: Select all
public ActionResult ExportPdf()
{
StiReport report = new StiReport();
report.Load(Server.MapPath("~/Content/Report.mrt"));
report.Render(false);
MemoryStream stream = new MemoryStream();
StiCsvExportSettings settings = new StiCsvExportSettings();
settings.Separator = ",";
settings.Encoding = Encoding.UTF8;
StiCsvExportService service = new StiCsvExportService();
service.ExportCsv(report, stream, settings);
this.Response.Buffer = true;
this.Response.ClearContent();
this.Response.ClearHeaders();
this.Response.ContentType = "application/pdf";
//this.Response.AddHeader("Content-Disposition", "attachment; filename=\"report.pdf\"");
this.Response.ContentEncoding = Encoding.UTF8;
this.Response.AddHeader("Content-Length", stream.Length.ToString());
this.Response.BinaryWrite(stream.ToArray());
this.Response.End();
}
Re: export to csv options
Hello.
Thank you.
We need some time to made an improvement of your issue. There is no solution now but it will be available in one of our next builds.brianj774 wrote:What I'm trying to do is to change the default settings for the dialog that pops up when a use selects save | Data | CSV File...
When the dialog opens, it shows page range gouping, and a settings grouping. Right now, the encoding defaults to Cyrillic for us, and we need this to be ASCII (UTF-8 may also be okay). The Separator option is set to ( ; ) semicolon, and needs to be ( , ) comma.
But, I would also accept a way to supress the ExportSettings dialog, and just manage the export entirely from code....I've found a way to do that "ShowExportDialog" and set to false, but I don't see how to then differentiate between all the different other export types. What I really want, is to just supress the CSV export dialog, and then to set the properties by hand as needed.
Please walk me thorough exactly what needs to be done to resolve this issue.
Thank you.
Re: export to csv options
In case anybody in interested, here's the solution I came up with...its far from perfect, but gets me where I need to go (for now). Future features from Stimulsoft will be most welcome
.
====================

====================
Code: Select all
public FileResult ExportReport() {
// Return the exported report file
var report = StiMvcViewer.GetReportObject(httpCtx);
var format = httpCtx.Request.Form["exportformat"];
var filename = String.Format("{0:s}_report.", DateTime.Now);
var contentType = "";
if (format == "Csv")
{
contentType = "text/csv";
filename += "csv";
var service = new StiCsvExportService();
var settings = new StiCsvExportSettings();
settings.Encoding = System.Text.Encoding.UTF8;
settings.Separator = ",";
var stream = new MemoryStream();
service.ExportCsv(report, stream, settings);
return File(stream.ToArray(), contentType, filename);
}
if (format == "Excel") {
contentType = "application/vnd.ms-excel";
filename += "xls";
var service = new StiExcelExportService();
var settings = new StiExcelExportSettings();
settings.ExportDataOnly = true;
var stream = new MemoryStream();
service.ExportExcel(report, stream, settings);
return File(stream.ToArray(), contentType, filename);
}
return StiMvcViewer.ExportReportResult(httpCtx);
}
Re: export to csv options
Hello.
In this code you overwrite the user settings. No matter what user will set.
Thank you.
In this code you overwrite the user settings. No matter what user will set.
Thank you.
Re: export to csv options
in my solution, the users settings will (ultimately) come from a preferences dialog in a different part of the system..
But, in a previous post in this thread, I'd said that I will be setting "ShowExportDialog" to false, so, there will be no user settings for the user to set.
however, your concern is right on, which is why I was asking for a way to be able to 'preset' the user settings dialog, instead of this. This solution is a functional workaround until that other feature becomes available.
But, in a previous post in this thread, I'd said that I will be setting "ShowExportDialog" to false, so, there will be no user settings for the user to set.
however, your concern is right on, which is why I was asking for a way to be able to 'preset' the user settings dialog, instead of this. This solution is a functional workaround until that other feature becomes available.