How to convert the excel file format to 97 format through code?

Posted by Vijetha under C# on 4/18/2012 | Points: 10 | Views : 2227 | Status : [Member] | Replies : 8
Hi All,
i generate the excel file in 2010 format but i need to convert any latest excel format also to 97 format.
How do and where do i specify the format for conversion in code?Im using response object to generate the excel file....
Please help for it.Urgent requirement.




Responses

Posted by: Gsm_Gsv on: 4/18/2012 [Member] Starter | Points: 25

Up
0
Down
Refer these links

http://www.codeproject.com/Articles/246772/Convert-xlsx-xls-to-csv
https://gist.github.com/924413

---------------------------------------
Live the life you've dreamed

Regards
MADHU

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

Posted by: Vijetha on: 4/18/2012 [Member] Starter | Points: 25

Up
0
Down
Thats not matching my requirement.can u suggest something else....

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

Posted by: Gsm_Gsv on: 4/18/2012 [Member] Starter | Points: 25

Up
0
Down
Do you want to export filename.xls from asp.net?

---------------------------------------
Live the life you've dreamed

Regards
MADHU

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

Posted by: Gsm_Gsv on: 4/18/2012 [Member] Starter | Points: 25

Up
0
Down
This may help you
Response.AppendHeader("Content-Disposition","attachment;filename="+DateTime.

Now.ToString("yyyyMMdd")+".xls");


---------------------------------------
Live the life you've dreamed

Regards
MADHU

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

Posted by: Vijetha on: 4/18/2012 [Member] Starter | Points: 25

Up
0
Down
this is how im creating now....
using (FileStream fileStream = new FileStream(Constants.EXCELFILESLOCATION + parameters.ReportName, System.IO.FileMode.Create))
{
using (StreamWriter streamWriter = new StreamWriter(fileStream))
{
streamWriter.Write(sb.ToString().Trim());
}
}


How do i convert it to EXCEL972003 format??????????

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

Posted by: Gsm_Gsv on: 4/18/2012 [Member] Starter | Points: 25

Up
0
Down
I am not getting exactly what you are going to do.
1. Have you created excel file from code in 2010 format? or
2. Are you importing an xlsx file, and do you want that to write into xls format from code? or
3. You just need to export from dataset to 2003 and 2010 formats?

---------------------------------------
Live the life you've dreamed

Regards
MADHU

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

Posted by: Sunny4989 on: 4/18/2012 [Member] Starter | Points: 25

Up
0
Down
Add the below code

ThisWorkbook.SaveAs "C:\test" & ".xls", FileFormat:=56



------------------------------------------------
Learn throughout life

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

Posted by: Sebas on: 3/1/2013 [Member] Starter | Points: 25

Up
0
Down
Hello,
The easiest and fastest way to work with Excel in C# is to use some 3rd party component.
You might want to look at this solution:
http://www.eleriumsoft.com/Excel_NET/ExcelNET/Default.aspx
I think this code will be helpul for you:

//if you want to convert existing file
ExcelWorkbook Wbook = ExcelWorkbook.ReadXLSX(@"c:\test.xlsx");
Wbook.WriteXLS(@"c:\test.xls");
//if you want generate a new file and save it in diferent format
ExcelWorkbook wb = new ExcelWorkbook();
wb.Worksheets.Add("sh1");
wb.Worksheets[0].Cells["A1"].Value = "text";
Wbook.WriteXLS(@"c:\test.xls");
Wbook.WriteXLSX(@"c:\test.xlsx");


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

Login to post response