Winforms - Export to Excel using Microsoft (Trusted) dll

Posted by Madhavi under C# on 12/6/2010 | Points: 10 | Views : 6329 | Status : [Member] | Replies : 5
Hi

In my WINFORMS applicatin i want to implement export to excel functionality . When i searched , found RKLIb.Export Data.dll for which we can pass datatable and file name which is "really very useful". But my client need trusted dll . Is there dll from Microsoft which i can use for export to excel .

If so, Please guide me.


Requirement :
when user clicks on "Export to excel" link , pop up window should open with "Open" "Save" Cancel" ( Hope got it)

Note :I see this Microsoft.Office.Interop.Excel.dll using in web applications. IF this is useful for Winforms , pls send the link to download as this is from MICORSOFT.

Please help me on this.

madhavi




Responses

Posted by: T.saravanan on: 12/6/2010 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi Madhavi,

Try the following links...

http://support.microsoft.com/kb/306023 // In this link there is no need any dll and also pass the Output path

http://www.eggheadcafe.com/community/aspnet/2/10225917/export-dataset-to-excel-in-windows-applicationwinforms.aspx

http://stackoverflow.com/questions/2408764/export-data-in-microsoft-excel-using-c-windowsforms-application

Cheers :)

Thanks,
T.Saravanan

Madhavi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Madhavi on: 12/6/2010 [Member] Starter | Points: 25

Up
0
Down
Hi Saravanan

Thanks a ton. First link helped me alot. Written in the see documetation for more details . But couldn't

Need one more help I want a pop up which wiill ask for open, save, cancel options

when i use excel.save() pop up window opens and prompts user to give file name to save( similar to "Save as" window)


When i type excel and dot (excel. ) showing lots of options. But which one will serve my purpose. Making trial and error from my end. If you know pls let me know.

which option i have to use for the required pop up. We want to leave to users choice whther he want to "Save" or Open that or Cancel.



Madhavi

Madhavi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Madhavi on: 12/6/2010 [Member] Starter | Points: 25

Up
0
Down
Saravanan,
sorry, not first link, second one helped me
http://www.eggheadcafe.com/community/aspnet/2/10225917/export-dataset-to-excel-in-windows-applicationwinforms.aspx


When i use excel.Save("xyzdata.xls"), it is not showing the file name, showing SHeet1.xls instead of given filename .
I don't want user to type the name also. How to get the file name automatically and also FIle Download window should appear with three options Save Open Cancel



Thanks
Madhavi

Madhavi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: T.saravanan on: 12/6/2010 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi Madhavi,

Using FolderBrowserDialog Control in your form you can solve your problem.
and also using one TextBox and Button Control for user save the excel file.

In your TextBox user enter the file name (ex:Test)
After enter the name and then click the button at the time use the following code...

if(folderbrowserdialog1.ShowDialog() == DialogResult.OK)
{
string sPath = folderbrowserdialog1.SelectedPath;
string sFileName = txtBox.Text + ".xls"; // Add the file format
sPath = sPath +"\\" + sFileName ;
// Now you pass the sPath into your Export to Excel Method.
}


Just try this way...

Cheers :)

Thanks,
T.Saravanan

Madhavi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: T.saravanan on: 12/6/2010 [Member] [MVP] Silver | Points: 25

Up
0
Down
Hi Madhavi,

My Suggestion is just create one popup form for your requirement.At that form have three buttons Open,Save and Cancel.
In your output form user click the button means just pass the datatable into that popup form using constructor.
If user click open button means write your data into excel and then open that file without save.
else click save button means call the SaveFileDialog object in that button event to get the path and pass the path into export to excel method.
click cancel means use this.Close() to close the form.

Note: All the methods are created in popup form.Try this way...


Thanks,
T.Saravanan

Madhavi, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response