7. Double click on the Button and pest the following code into the “btnCreateExcel_Click” event

//Add a reference to excel.application

Excel.Application exc;

try

{

//Creating new excel.application

exc = new Excel.Application();

//To make application visible

exc.Visible = true;

//To get the workbooks collection and add a new worksheet to workbook

Workbooks workbooks = exc.Workbooks;

_Workbook workbook = workbooks.Add(XlWBATemplate.xlWBATWorksheet);

//To save the excel file

exc.Save(txtExcelFileName.Text + ".xls");

MessageBox.Show("Excel file created successfully.");

txtExcelFileName.Text = "";

}

catch (Exception ex)

{

MessageBox.Show(ex.Message.ToString());

}

finally

{

exc = null;

}

Press F5 to build and run the project.

8. Put your excel file name with location like c:\MyExcelFile.xls in the text box and then press the “Create Excel File” Button. An excel file by the name MyExcelFile.xls will be created at the specified location.

This website uses cookies

As a user in the EEA, your approval is needed on a few things. To provide a better website experience, hubpages.com uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

This is used to display charts and graphs on articles and the author center. (Privacy Policy)

Google AdSense Host API

This service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)

This is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)

Facebook Login

You can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)

Maven

This supports the Maven widget and search functionality. (Privacy Policy)

We may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.

Conversion Tracking Pixels

We may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.

Statistics

Author Google Analytics

This is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)

Comscore

ComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)

Amazon Tracking Pixel

Some articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)