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

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Save excel in .xslx format using c#

Posted By:      Posted Date: August 24, 2010    Points: 0   Category :ASP.Net


My existing code converting xml in to excel and it is saving excel in .xls format.

But i need to save it in .xlsx format .

Existing code for converting xml...

XmlDataDocument xmlDataDoc = new XmlDataDocument();
            XslCompiledTransform xslTransform = new XslCompiledTransform();
            // Generate Excel Report
            using (XmlTextWriter xmlWriter = new XmlTextWriter(outputFileAndPath, System.Text.Encoding.UTF8))
                xmlWriter.Formatting = Formatting.Indented;
                xmlWriter.Indentation = 3;

View Complete Post

More Related Resource Links

Microsoft Office Excel cannot open or save any more documents because there is not enough available


hi all,

     i am new to asp.net programming i am trying to create an ms excel file with charts drawn in it,

i wrote the complete code for it but the it is saying

Microsoft Office Excel cannot open or save any more documents because there is not enough available memory or disk space. 

i have set the permissions to my complete disk space and all user accounts, and i tried with anti-virus disabling also it didnt work please try to help me out and my code is :

Imports System.Data.OleDb
Imports Microsoft.Office.Interop
Imports Microsoft.Office.Tools.Excel
Imports System

Excel Interop Save as



I want to Save excel workbook using Excel interop in 97-2003 format. Currently I have Office 2007 installed on my machine.

below is the code I am using.

_book.SaveAs("New.xls", Excel.XlFileFormat.xlWorkbookDefault, Missing.Value, Missing.Value, false, false, Excel.XlSaveAsAccessMode.xlNoChange, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);

The solution is little urgent.


System.Runtime.InteropServices.COMException (0x800A03EC): Microsoft Excel cannot open or save any mo


Hello good people, 

I have this beast as an error. Did my research and found some posts here as well but did not do any good for me. 

Here is what I did. I had an error regarding issue rights with COM objects so I gave access rights under component services for Microsoft Excel application now I am getting this error. 

Here is some information regarding this

1. Gave rights to ASPNET and network service to my web app directory to try to fix this error. 

2. The exact same process works on my Windows 2003 server and my Windows 7 development machine. I am trying to get this going on a different windows 2003 machine that is outside of our domain.

3. Developing on windows 7 64 bit with office 2010 installed. Also excel 2010 is installed on my Web server

4. Here is the code that is causing the error: The last line is causing the error.:

            MyXl = new Microsoft.Office.Interop.Excel.Application();
            MyXl.Visible = false;
            MyWb = (Microsoft.Office.Interop.Excel._Workbook)(MyXl.Workbooks.Add(Missing.Value));
            int test = 0; 
            MySheet = (Microsoft.Office.Interop.Excel._Worksheet)MyXl.ActiveSheet;
            if (reader.HasRows)
                int InRow = 2; 
                for (int i = 0; i < Nu

Export Dataset to excel sheet in a required format?



I know how to export a grid view to excel.

But here i have a Dataset which consists of data like below and also it need to display in a required format like below.

pno psubno pstate pdetailid pdetails

 12    1          CA         1           cbsdjcbdjc     

12     1          CA          2        cndcnjdcjcj

12     2           VA         4          xcndwkfcgygry

13     1            AL        1           ncdcnjdcndj

My excel sheet  should like this.

pid       pstate     

 12/1      CA             &nb

format row in excel

i export datagridview datat to excel,but now how to format the first row to BOLD  Excel.ApplicationClass ExcelApp = new Excel.ApplicationClass(); ExcelApp[1,1]="AAA"; how to format this cells to bold

Would like to use an Excel file on the net then save changes

I have an excel sheet that i would like to use on the net. I can convert it using spreadsheetconverter but it will not save the changes as it converts it to an htm file.  But works (limited functions though, it wont convert sliders) Can I use VWD somehow so it reads the excel file and then if I make changes, to save them to the file. So when I view it again no the net it sees the changes?? Goal is the use the excel file on the net without having to have it on someones computer I just started VWD  

Trouble importing strange column format report from Excel 2007 to SQL 08

Hi, I'm not sure whether this belongs in this section or the SSIS one so hopefully I've got it right!  Hoping someone will be able to help with a problem I'm having importing a report with header and detail rows from our antiquated POS system into SQL 2008 tables.  The reports export in Excel 2007 format and for each header row there can be one or more detail rows starting from column B.  As such I've tried several things such as openrowset, an Access 12.0 OLE DB source in SSIS and even COM automation of Excel to try and write a conditional split which will hold the header details in variables then write them to rows alongside the detail rows.  I've pasted a small sample of the data here as I wasn't able to attach it: 01/07/2010 @ 11:18 Page: 1 RECEIVING: Voucher Journal Sort: VC|Str|Vou Date|Vou #|Document SID Filter: Voucher Date: 01/06/2010@12:00a..30/06/2010@11:59p Include Item detail: DCS|Item#|Desc1|Attr|Material|Size|Qty VC Str Vou Date Vou # Qty ABC 001 15/06/2010 12345 38 E NN 66 200148 XXXXXXXX RED SHAD E NN 66 200149 YYYYYYYYY BLACK GO E PP 60 200154 ZZZZZZZZZ BLACK CDE 002 16/06/2010 13839 8 F SA 35 217500 XXXXXXXX Natural F SA FL 218674 YYYYYYYYY Chalk F SA WE 221462 ZZZZZZZZZ White FGH 001 21/06/2010 13905 3 F SH 85 126260 XXXXXXXX Navy IJK 001 23/06/2010 13914 3 E AA 61 250005 YYYYYY

Unable to export data to an excel file in grid format!!!

I'm exporting data to an excel sheet from the ojects list. The data is exporting to excel sheet well, but I'm unable to see the grid format for the data. The data is looking with out the rows and columns lines. I think I'm missing to set some property or somethnig ehwn exporting.   Any help would be really appriciated.

date format in excel using c#

i have a datagridview and one of the column is date with format dd/MM/yyyy HH:mm:ss but when i export to excel the date format become 'd/m/yy HH:mm' how can i format the column in excel with the date format 'dd/MM/yyyy HH:mm:ss' i am using below method Excel.ApplicationClass ExcelApp = new Excel.ApplicationClass(); Excel._Worksheet oSheet;  oSheet = (Excel._Worksheet)oWB.Worksheets[1];

ASP.NET-Gridview - Export to excel- column format

Hi All, I am exporting gridview data into excel sheet. I have a column  which is a code for which data is like 012,013 etc. But when this data is being exported , in the excel sheet I can see the data as 12,13,14. but actually it should be 012.... Is there any way to specify the format of such columns in my datatable so that they are in the same manner as in the database? Please provide some information on this.Thanks in advance.

Anonymous access on Excel Viewer web part for a no access .xslx file?

I have a public facing SharePoint 2010 Enterprise website with anonymous access enabled. I'd like to present information (a pivot chart) from an .xslx file using the Excel Viewer Web Part. It works fine when I place the .xslx file in a document library that the anonymous users can access. I would, however, like to remove anonymous access from the .xslx file and only expose the chart from the .xslx file using the Excel Viewer web part. When I alter the library permissions to remove anonymous access to the library that holds the .xslx file, the Excel Viewer web part displays an "Access Denied" message to the anonymous user. Is there some other way to achieve this?

SSRS 2005 Render Format Excel Issue with Time Field


I have a report that uses a datetime field but gets populated only with the time. So, in SQL db, it gets stored with a default date value of 1899-12-30 12:01:01 with the correct time filled in. Report in SSRS Preview mode displays the value just fine when I use the Time format in Layout mode. I build and deploy and able to view the report in a web browser with no problem displaying the time field. But when I subscribe to the report and choose Excel render format, when I open up the Excel file from the email that was sent, I get negative decimal values. I have tried every possible Time format in SSRS but I get the same result. I also tried just the default and still gives me negative decimal values that show up as ####### in Excel.

Any help will be greatly appreciated. Thanks

How to Convert Excel 2003 (.xls) format to Excel 2007 (.xlsx) programmatically in asp.net


Hi everybody

I am using a function to save dataset tables to excel files (some xml method http://www.codeproject.com/info/search.aspx?artkw=xls+to+xlsx&sbo=kw ) in xls format(excel 2003) but the excel file which is created taking 10 times more file size than conventional one.

And after that when I am converting to excel 2007 format I am getting the normal size for that file.

Now can anyone tell me how to convert excel 2003 file format to excel 2007 file format programmatically through asp.net

Thanks everyone in advance.


Difference in Excel Format Display in Different Machines when i export from ssrs2008R2


i develop one report  and i am using ssrs2008R2

  • when i exporting into excel sheet its dispaly perferct in my mechine (means printview shows perferct with looose any column )
  • when my tester exporting into excel sheet its dispaly different meas missing last coloums in report  

Both are using WINDOWS7 Enterprice ,office2007 ,ssrs2008R2  

Please note that the reports gets generated in my machine, say System A, as expected. But as I figured out that in some machines, say System B,  the reports generated are having alignment problems.
I had compared the System A and System B machines in the following parameters :
1) System Resolution - 1024x768 (Same)
2) Microsoft Office Excel Versions - 2007 (Same)
3) Remote Desktop Login into System B from System A -- Reports are properly displayed
    Remote Desktop Login into System A from System B -- Reports are not properly displayed

can Plz help me as possible as earliy

my mail address :praveen6867@gmail.com

Generate report in Excel format with formulas



I have a report with simple calculations (adds some fields). The report is requested in excel format via Reporting Services WebService.

I would like to have the generated excel file to have the formulas, not just the results. I tried to put the formula text in report definition, but it does't work, it appears in excel as text, not as formula.

How can I do this?



Save value in double value in specific format(00.00)


How can i assign a value in a double variable which would be in format 00.00

I want to do it while declaring or assigning the value.

i.e if should contain two digits and should be rounded off to two digits and 0 should be added if it has single digit.....


2 should be saved and later used as 02.00

27.7777777 -> 27.77 or 27.78;

Unable to save Excel files opened from SharePoint

Hi all!

From time to time users have problem saving excel files that they have opened from a SharePoint document library.

Error message:

"Document could not be saved"

It's not possible to save it localy ither.

Any ideas?

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

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