Click here to Skip to main content
15,896,153 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
C#

hi, how can SaveAs an excel file in c# without used of dll or namespace?
Posted
Comments
Hemant Singh Rautela 23-Jan-13 3:15am    
Your Question is not clear, what do you want Download/Upload or convert database report to excel..???

1 solution

Hello, f_gharavi

If the Excel file is just missing the extension "xls" or "xlsx" you can change the extension using C#:

C#
Path.ChangeExtension(path, ".xls");


* If is not excel, then you need to create an excel file, fill it with your data, according to the specific parser of your data etc.

-----------------
If you just want to copy the file to another location and change it's name, use CopyTo:

C#
string DestinationPath = @"D:\NewFile.xls";
FileInfo fi = new FileInfo(@"C:\SoureFile.xls");

fi.CopyTo(path2);




Cheers,
Edo
 
Share this answer
 
v2
Comments
f_gharavi 26-Jan-13 5:27am    
Thank you for your solution, But I have an excel file and I want read that file by C# code and SaveAs that file in another directory with diferent Name, like I have an excel file in c:\ derive and I want read that with c# and SaveAs that in D:\ drive
Joezer BH 27-Jan-13 0:45am    
Hi, Gharavi,
Added your request to the solution above,

Cheers,
Edo

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