David是正確的,Excel 2003和以前版本的Excel僅限於56色調色板。
Excel 2007增加了對24位色以及主題顏色的支持。 Excel 2007可以編寫包含此附加顏色信息和Excel 2003可以讀取的xls工作簿,但Excel 2003仍將限制爲56色調色板。 Excel 2007可以加載這些工作簿並顯示確切的顏色。
支持新的24位顏色和主題顏色,以及舊的調色板索引顏色,就像Excel 2007一樣。您可以使用SpreadsheetGear創建一個24位顏色的工作簿,該工作簿將在Excel 2007中正確顯示,或者修改調色板,並且它們將在Excel 2007和Excel 2003中正確顯示。下面是兩個示例。
您可以下載免費試用here並自己嘗試。
聲明:我自己的SpreadsheetGear LLC
下面是示例代碼:
// Create a new empty workbook with one worksheet.
IWorkbook workbook = Factory.GetWorkbook();
// Get the worksheet and change it's name to "Person".
IWorksheet worksheet = workbook.Worksheets[0];
worksheet.Name = "Colors";
// Put "Hello World!" into A1.
IRange a1 = worksheet.Cells["A1"];
a1.Value = "Hello World!";
a1.Font.Color = System.Drawing.Color.FromArgb(0x8C, 0xBE, 0x50);
// Save the workbook as xls (Excel 97-2003/Biff8) with default palette.
//
// This workbook will display the exact color in Excel 2007 and
// SpreadsheetGear 2009, but will only display the closest available
// palette indexed color in Excel 2003.
workbook.SaveAs(@"C:\tmp\GreenDefaultPalette.xls", FileFormat.Excel8);
// Save as xlsx/Open XML which will also display the exact color.
workbook.SaveAs(@"C:\tmp\GreenDefaultPalette.xlsx", FileFormat.OpenXMLWorkbook);
// Now, modify the palette and save. This workbook will display the exact
// color in Excel 2003 as well as in SpreadsheetGear 2009 and Excel 2007.
//
// Note that modifying the palette will change the color of any cells which
// already reference this palette indexed color - so be careful if you are
// modifying pre-existing workbooks.
workbook.Colors[0] = a1.Font.Color;
workbook.SaveAs(@"C:\tmp\GreenModifiedPalette.xls", FileFormat.Excel8);