Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Sat Oct 23, 2021 2:01 pm

Hi Team E-ICEBLUE,
I have a query that while exporting two datatables in excel two sheets and if i got values change from one sheet to second sheet so change the color of cells on both sheet
Attachments
01.JPG
Sample Output Which i want aftr export DataTable to Excel in two sheets
01.JPG (62.05 KiB) Viewed 1827 times

MSAQIBABBASI
 
Posts: 11
Joined: Mon Jul 05, 2021 8:08 am

Mon Oct 25, 2021 7:01 am

Hello Muhammad,

Thanks for using our Spire.XLS.
Please compare the data for cells in the same position between sheet one and sheet two. If it's inconsistent, please set its background color.
Code: Select all
   
           Workbook workbook = new Workbook();
            workbook.CreateEmptySheets(2);
            Worksheet worksheet1 = workbook.Worksheets[0];
            worksheet1.InsertDataTable(DataTable1, true, 1, 1);
            Worksheet worksheet2 = workbook.Worksheets[1];
            worksheet2.InsertDataTable(DataTable2, true, 1, 1);
            CellRange range1A1 = worksheet1.Range["A1"];
            CellRange range2A1 = worksheet2.Range["A1"];
            if (!range1A1.Value.Equals(range2A1.Value))
            {
                range1A1.Style.KnownColor = ExcelColors.Yellow;
                range2A1.Style.KnownColor = ExcelColors.Yellow;
            }


Feel free to contact us if any questions.

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2767
Joined: Wed Jun 27, 2012 8:50 am

Thu Oct 28, 2021 7:54 am

Hello Muhammad,

Hope you are doing well.
Has your issue been solved?
I would greatly appreciate your feedback.


Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2767
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.XLS