xlsgen > overview > Transparency

 

Transparency is a formatting property of a number of elements in spreadsheets. It makes it possible to see through elements. Transparency can be applied to :

 


Transparency in charts (horizontal gridlines not obscured by area and bar elements; area not obscured by bar elements)

In the chart above, horizontal gridlines are not obscured by chart elements. And chart elements themselves do not obscur each other. Usually producing a more readable and nicer chart.

Transparency is exposed in the xlsgen object model through a simple FillTransparency property, whose value ranges from 0 (opaque) to 100 (fully transparent).

When a gradient fill is used, there is a fill transparency value for each gradient stop. For instance, for a 2-stop gradient fill, transparencies available are respectively FillTransparency[0] and FillTransparency[1].

Here is an example in C++ showing how to set transparency to a chart, producing the chart pictured above. Note that most of the source code is for the chart set up, not the transparency itself :

C/C++ code

    xlsgen::IXlsChartPtr chart001s0 = worksheet->NewChart(xlsgen::charttype_bar2D, 4, 5, 18, 10);

    xlsgen::IXlsChartDynamicDataSourcePtr datasource001s0 = chart001s0->DynamicDataSource;

    xlsgen::IXlsChartDynamicDataSourceSeriesPtr serie001s0ss0 = datasource001s0->AddSerie();
    serie001s0ss0->SeriesTitlesFormula = L"Sheet1!$C$2";
    serie001s0ss0->SeriesValuesFormula = L"Sheet1!$C$3:$C$10";
    xlsgen::IXlsChartDynamicDataSourceSeriesPtr serie001s0ss1 = datasource001s0->AddSerie();
    serie001s0ss1->SeriesTitlesFormula = L"Sheet1!$D$2";
    serie001s0ss1->SeriesValuesFormula = L"Sheet1!$D$3:$D$10";
    chart001s0->Legend->Show = xlsgen::chartlegend_hidden;

    chart001s0->MainTitle->Label = L"Chart transparency";

    // bar formatting (auto gradient fill, and 94% means we want the 2nd gradient stop almost fully transparent)
    chart001s0->SeriesByIndex[1]->Options->Patterns->Area->FillTransparency[1] = 94;

    // area formatting (50% means we want the solid area half opaque half transparent)
    chart001s0->SeriesByIndex[2]->SeriesType = xlsgen::charttype_area2D;
    chart001s0->SeriesByIndex[2]->Options->Patterns->Area->Type = xlsgen::chartareatype_custom;
    chart001s0->SeriesByIndex[2]->Options->Patterns->Area->Pattern->PatternStyle = xlsgen::chartareapattern_solid;
    chart001s0->SeriesByIndex[2]->Options->Patterns->Area->Pattern->BackgroundColor = 0xFF0000;
    chart001s0->SeriesByIndex[2]->Options->Patterns->Area->FillTransparency[0] = 50;

 

xlsgen documentation. © ARsT Design all rights reserved.