2009-10-06 8 views
1

일부 스프레드 시트 ML (XML)을 생성하여 사용자를위한 Excel 스프레드 시트를 만드는 툴을 작성 중입니다. 다음과 같이스프레드 시트 ML 텍스트 색상 (색상) 렌더링

나는 스타일을 정의 :

 
<Style ss:ID="GreenText"> 
    <Font ss:FontName="Arial" ss:Size="9" ss:Color="#8CBE50" /> 
</Style> 

이 어느 정도 작동하지만 Excel에서 열 때 텍스트로 렌더링 색상이 내가 지정한 아니다 - 그것은 밝은 버전입니다 . 셀 테두리에 동일한 색상 참조를 사용할 수 있으며 색상이 올바르게 렌더링됩니다.

텍스트 색상이 올바르게 렌더링되지 않는 이유에 대해 궁금한 점이 있으십니까?

감사합니다.

답변

0

엑셀의 팔레트는 56 색으로 제한됩니다. 실제 RGB 값보다는 색상 색인 만 저장합니다. 그들은 팔레트에서 사용자 정의 색상을 허용하지만, 나는 그들을 프로그래밍 방식으로 변경하는 방법을 모른다 .

편집 :
내가 사용하지 않은 오피스 XML 문서 만이 (팔레트를 정의 indexedColors 태그) 도움이 될 수 있습니다 :
http://openxmldeveloper.org/forums/thread/309.aspx

또한 VBA에서 팔레트를 변경하기위한 Workbook.Colors 속성이있다 .

1

Excel 2003 및 이전 버전의 Excel에서는 56 색 팔레트로 제한됩니다.

Excel 2007에는 테마 색뿐만 아니라 24 비트 색도 지원됩니다. Excel 2007에서는이 추가 색 정보가 포함되어 있고 Excel 2003에서 읽을 수있는 xls 통합 문서를 작성할 수 있지만 Excel 2003은 여전히 ​​56 색 팔레트로 제한됩니다. Excel 2007에서는 이러한 통합 문서를로드하고 정확한 색상을 표시 할 수 있습니다.

은 Excel 2007에서와 마찬가지로 새로운 24 비트 색 및 테마 색뿐만 아니라 이전 팔레트 색인 색을 지원합니다. 스프레드 시트 기어를 사용하여 24 비트 색상의 통합 문서를 만들면 Excel 2007에서 올바르게 표시되거나 팔레트가 수정되어 Excel 2007 및 Excel 2003에서 올바르게 표시됩니다. 아래 두 가지 예가 있습니다.

무료 시험판 here을 다운로드하여 직접 시도 할 수 있습니다.

면책 조항 :

  // 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); 
: 내가하는 SpreadsheetGear LLC는

다음 샘플 코드입니다 소유