troubleshooting Question

excel color range from C#

Avatar of gudidi
gudidiFlag for Israel asked on
XMLC#Microsoft Excel
2 Comments1 Solution579 ViewsLast Modified:
Hi Experts

i load data to datatable and export it to excel file or to excel spreadsheet as xml.
i determine the colors of range for both - the same.
sometimes i save it as XML spreasdheet and sometimes i save it as XLS file.
the result is that that the colors are different.

any idea how to save the range in the same color?

tese are th definitions:

range.Borders.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black);
range.Font.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Black);
range.Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Wheat);

and then i save it:

if (sType == "OUT")
                {

                    Temp = sFileName + Temp + ".xml";

                    objBook.SaveAs(sPath + "\\" + Temp,
                        Excel.XlFileFormat.xlXMLSpreadsheet,
                        System.Reflection.Missing.Value, System.Reflection.Missing.Value, false, false,
                        Excel.XlSaveAsAccessMode.xlExclusive,
                        Excel.XlSaveConflictResolution.xlLocalSessionChanges, System.Reflection.Missing.Value, System.Reflection.Missing.Value,
                        System.Reflection.Missing.Value, System.Reflection.Missing.Value);
                }
                if (sType == "IN")
                {
                    Temp = sFileName + Temp + ".xls";

                    objBook.SaveAs(sPath + "\\" + Temp,
                        Excel.XlFileFormat.xlExcel5,
                        System.Reflection.Missing.Value, System.Reflection.Missing.Value, false, false,
                        Excel.XlSaveAsAccessMode.xlExclusive,
                        Excel.XlSaveConflictResolution.xlLocalSessionChanges, System.Reflection.Missing.Value, System.Reflection.Missing.Value,
                        System.Reflection.Missing.Value, System.Reflection.Missing.Value);
                }

                objBook.Close(System.Reflection.Missing.Value, sPath + "\\" + sFileName, System.Reflection.Missing.Value);
                objBooks.Close();
                objApp.Quit();

10x for any idea.
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros