Click here to Skip to main content
15,943,623 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

I am converting resource file to excel in my web application and below is my code.

public void ConvertToExcel(ResXResourceReader reader, string fileName)
 exlObj = new Microsoft.Office.Interop.Excel.Application();
            Workbooks workbooks = exlObj.Workbooks;
            _Workbook workbook = workbooks.Add(XlWBATemplate.xlWBATWorksheet);
            Sheets sheets = workbook.Worksheets;
            _Worksheet worksheet = (_Worksheet)sheets.get_Item(1);
                             worksheet.Name = fileName;
                           Range range = worksheet.get_Range("A1", "B1");
                             range.set_Item(1, 1, "KEY");
                range.set_Item(1, 2, "VALUE");
                  int count = 2;
                foreach (DictionaryEntry entry in reader)
                    ResXDataNode node = (ResXDataNode)entry.Value;
                    AssemblyName[] assemblies = Assembly.GetExecutingAssembly().GetReferencedAssemblies();
                    range.set_Item(count, 1, entry.Key);
                    range.set_Item(count, 2, node.GetValue(assemblies).ToString());
                range.Sort(range.Columns[1, Type.Missing], XlSortOrder.xlAscending, range.Columns[2, Type.Missing], Type.Missing,
                            XlSortOrder.xlAscending,Type.Missing, XlSortOrder.xlAscending, XlYesNoGuess.xlNo, Type.Missing, Type.Missing, XlSortOrientation.xlSortColumns,
                            XlSortMethod.xlPinYin, XlSortDataOption.xlSortNormal, XlSortDataOption.xlSortNormal, XlSortDataOption.xlSortNormal);
I have to show this converted excel file using Response.Appendheader.(So that user can save it in their local drive). How can i do this?

This method is in separate class file . Please help me to get the saveas dialog with converted file in


[edit]Code Block added to preserve formatting - OriginalGriff[/edit]
Updated 1-Mar-11 23:34pm

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