Click here to Skip to main content
14,383,511 members
Rate this:
Please Sign up or sign in to vote.
See more:
hi i use this code
excelApp = new Microsoft.Office.Interop.Excel.Application();
                        excelBook = excelApp.Workbooks.Add(XlSheetType.xlWorksheet);
                        excelWorksheet =(Worksheet)(excelBook.Worksheets[1]);
                        excelApp.Visible = true;
                        excelWorksheet.DisplayRightToLeft = true;
                        rng1 = excelWorksheet.get_Range("A1", "A1");
                        rng1.Value2 = "__ID__";
                        rng1.Font.Bold = true;
                        rng2 = excelWorksheet.get_Range("B1", "B1");
                        rng2.Value2 = "ID";
                        rng2.Font.Bold = true;
                        rng3 = excelWorksheet.get_Range("C1", "C1");
                        rng3.Value2 = "Title";
                        rng3.Font.Bold = true;
                        i = 1;
                        foreach (DataRow r in ds.Tables[0].Rows)
                        {
                            i++;
                            string s = i.ToString();
                            Range r1 = excelWorksheet.get_Range("A" + s, "A" + s);
                            r1.Value2 = r[0].ToString();
                            Range r2 = excelWorksheet.get_Range("B" + s, "B" + s);
                            r2.Value2 = r[1].ToString();
                            Range r3 = excelWorksheet.get_Range("C" + s, "C" + s);
                            r3.Value2 = r[2].ToString();
                        }

for Export data to Excell.
some time ,i have an Error!

"""Exception from HRESULT:0x800AC472"""
pleas help me!!
Posted

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100