.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> Windows Form Controls >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Export to Excel in VB.NET

Posted By:Athira Sreejith       Posted Date: February 22, 2009    Points: 10    Category: Windows Form Controls    URL: http://www.dotnetspark.com  
 

Export to Excel in VB.NET windows application. Below is the code to export data to MS Excel .

SaveFileDialog saveFileDialog1 = new SaveFileDialog();

saveFileDialog1.Filter = "Excel Files (*.xls)|*.xls" ;

saveFileDialog1.RestoreDirectory = true ;

saveFileDialog1.Title="Save To Excel File";

if(saveFileDialog1.ShowDialog() == DialogResult.OK)

{

try

{

string filePath="";

System.IO.FileStream fs = (System.IO.FileStream)saveFileDialog1.OpenFile();

filePath = saveFileDialog1.FileName;

fs.Close();

fpSpread1.SaveExcel(filePath,FarPoint.Win.Spread.Model.IncludeHeaders.BothCustomOnly);

MessageBox.Show("Exported to excel file.");

SetIntial();

}

catch(Exception exp)

{

WinUtil.ShowError(exp);

}

}


     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend