Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 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:tmpGreenDefaultPalette.xls", FileFormat.Excel8);
- // Save as xlsx / Open XML which will also display the exact color.
- workbook.SaveAs(@"C:tmpGreenDefaultPalette.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:tmpGreenModifiedPalette.xls", FileFormat.Excel8);
- // 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:tmpGreenDefaultPalette.xls", FileFormat.Excel8);
- // Save as xlsx / Open XML which will also display the exact color.
- workbook.SaveAs(@"C:tmpGreenDefaultPalette.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:tmpGreenModifiedPalette.xls", FileFormat.Excel8);
Add Comment
Please, Sign In to add comment