Free Support Forum - aspose.com

Problem Changing bacground color

  1. I have a problem with changing Background,
    I’ve tried to follow an example from another thread, but it did not solve the problem. The background remains unchanged(i.e. default). all the data is being importec correctly
    btw, where do numbers 54 & 55 in your example come from?

    2) Also, could you please let me know if you have any recommendation on improving the workflow
    (the idea is that I want to combine smart markers with using ImportDataTable/ImportColumn)
    I can’t use smart markers to import columns, because the columns&headers may change depending on the search criteria (or is there still a way to use smart markers if the columns are dynamically generated?)
    when I create excel file for download, I have: DataGrid which has column headers and bound to the datatable which has one page of data, and a different data table that has the same structure, but all the data(this it the table that should be downloaded).

    here is the code I use:

    ExcelDesigner designer = new ExcelDesigner();

    …// read template file in to stream
    designer.Open(memoryStream);
    // file has one worksheet with some variables i.e. &=$test

    designer.SetDataSource(“test”,“value”); // this works fine
    designer.process();


    designer.Excel.worksheets.Add();
    int sheetNumber=designer.Excel.Worksheets.Count-1;

    designer.Excel.ChangePalette(Color.DarkBlue,55);

    //
    for( each column)
    {
    // import column

    designer.Excel.Worksheets[sheetNumber].Cells[row,column].Style.BackgroundColor=Color.DarkBlue; // change background for header

    }

    designer.SaveToStream(…)

  1. Please change your code to

    designer.Excel.Worksheets[sheetNumber].Cells[row,column].Style.ForegroundColor=Color.DarkBlue;

    There are 56 different colors in a standard Excel palette. You can see it when you format a cell. To add an extra color to the file, you have to change the palette at first. About the 56 colors of the palette, please check http://www.aspose.com/Products/Aspose.Excel/Api/Aspose.Excel.Excel.ChangePalette.html

    2. You can use Cell.PutValue to put smart markers at run time, and then set data source, finally call process method. Then you can dynamically process the data with smart markers.