Click here to Skip to main content
15,888,323 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi! i have the code for saving a gridview as an html file using a savefiledialog. i want to save it to a specific path (without using the savefiledialog)... how can i do that?

here's my code:

SaveFileDialog dialog = new SaveFileDialog();
dialog.DefaultExt = "*.html";
dialog.Filter = "WORD Document (*.html)|*.html";

if (dialog.ShowDialog() == true)
{
	RadDocument document = CreateDocument(rgvReportData);

	document.LayoutMode = DocumentLayoutMode.Paged;

	document.Measure(RadDocument.MAX_DOCUMENT_SIZE);
	document.Arrange(new RectangleF(PointF.Empty, document.DesiredSize));
	document.SectionDefaultPageMargin = new Telerik.Windows.Documents.Layout.Padding(2, 2, 2, 2);
	document.SectionDefaultPageOrientation = PageOrientation.Landscape;
	
	HtmlFormatProvider provider = new HtmlFormatProvider();

	using (Stream output = dialog.OpenFile())
	{
		provider.Export(document, output);
	}
} 


how can i sve it without using a savefiledialog?
Posted

1 solution

In the last sentence, the "using":

using (Stream output = File.OpenWrite(@"C:\myreport.html")) // or whatever path.
    provider.Export(document, output); // Remember "using System.IO;"


By the way, just remove any code related to the file save dialog.
 
Share this answer
 
v3
Comments
Member 7838027 19-May-11 23:10pm    
thanks. here's now my code:
RadDocument document = CreateDocument(rgvReportData);
document.LayoutMode = DocumentLayoutMode.Paged;
document.Measure(RadDocument.MAX_DOCUMENT_SIZE);
document.Arrange(new RectangleF(PointF.Empty, document.DesiredSize));
document.SectionDefaultPageMargin = new Telerik.Windows.Documents.Layout.Padding(2, 2, 2, 2);
document.SectionDefaultPageOrientation = PageOrientation.Landscape;
HtmlFormatProvider provider = new HtmlFormatProvider();
using (Stream output = File.OpenWrite(@"C:\myreport.html"))
{
provider.Export(document, output);
}


nut it didn't work.
Member 7838027 20-May-11 1:53am    
there's no error messages shown but the file is not created.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900