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.

Tue Oct 24, 2017 6:54 am

Hi, Is there other way to set value on Color property on workbook?

jypmrls
 
Posts: 6
Joined: Tue Oct 24, 2017 6:39 am

Tue Oct 24, 2017 7:27 am

Hi jypmrls,

Thanks for your inquiry.
Please refer to code below.
Code: Select all
            sheet.Range["A1"].Style.Color = Color.Black;
            sheet.Range["B1"].Style.Color = Color.FromArgb(255, 0, 176, 80);
            sheet.Range["C1"].Style.Color = Color.FromName("red");
            sheet.Range["D1"].Style.Color = Color.FromKnownColor(KnownColor.AliceBlue);

If I misunderstand your need, please describe it in detail.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Tue Oct 24, 2017 7:46 am

Thanks for the reply but that is not what i wanted to do. I'm merging 2 excel file into 1 I have successfully merge the file but the color is not the same.

jypmrls
 
Posts: 6
Joined: Tue Oct 24, 2017 6:39 am

Tue Oct 24, 2017 7:49 am

Hi jypmrls,

Thanks for your feedback.
Please provide us with below information for further investigation.
1. the input and output documents
2. the code you were using

Thanks,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Tue Oct 24, 2017 8:15 am

Im using your code snippets to merge the file
Attachments
mergeExcel.zip
(17.91 KiB) Downloaded 244 times

jypmrls
 
Posts: 6
Joined: Tue Oct 24, 2017 6:39 am

Tue Oct 24, 2017 8:50 am

Hi jypmrls,

Thanks for sharing the files.
Please take the file(Input.XLS) as the target document, then add sheet from the file(Input (2).XLS).
Sample code:
Code: Select all
            Workbook target = new Workbook();
            target.LoadFromFile(path + "Input.XLS");
            Workbook file1 = new Workbook();
            file1.LoadFromFile(path + "Input (2).XLS");
            foreach (Worksheet sheet in file1.Worksheets)
            {
                target.Worksheets.AddCopy(sheet);
            }
            target.SaveToFile("11957result.xlsx",ExcelVersion.Version2010);

If there is any question, please let us know.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Tue Oct 24, 2017 9:02 am

Hi,


Thank you for the response.
But we have a problem with that code.
If I do that they switch the sheet position.

jypmrls
 
Posts: 6
Joined: Tue Oct 24, 2017 6:39 am

Tue Oct 24, 2017 9:30 am

Hi jypmrls,

Did you want to reorder the position of the worksheets ?
If so, please use following code.
Code: Select all
            target.Worksheets[0].MoveWorksheet(1);

If not, please tell us your issue detailedly.

Thanks,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Tue Oct 24, 2017 9:45 am

Hi,

I will to reorder the sheet.

Thank you so much !

jypmrls
 
Posts: 6
Joined: Tue Oct 24, 2017 6:39 am

Tue Oct 24, 2017 10:00 am

Hi,

It's working !

Thank you so much !

jypmrls
 
Posts: 6
Joined: Tue Oct 24, 2017 6:39 am

Tue Oct 24, 2017 10:01 am

Hi jypmrls,

Thanks for your response.
One more thing, as for your two documents, if I copy the sheet in the file(Input.XLS) into the file(Input (2).XLS) via Excel, the color indeed changed. Considering this specific situation, I suggest you take the file(Input.XLS) as target file.
Any question, please feel free to contact us.

Sincerely,
Betsy
E-iceblue support team
User avatar

Betsy.jiang
 
Posts: 3099
Joined: Tue Sep 06, 2016 8:30 am

Return to Spire.XLS