logo
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
epf  
#1 Posted : Tuesday, March 29, 2016 7:39:17 AM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 576
Switzerland

Thanks: 7 times
Was thanked: 84 time(s) in 81 post(s)
For people using the Excel Converter Component, there is an issue with the Charts generation in Excel (values are not sorted...).
The workaround is the following:

Just select your main view, and edit the property: 'Excel Configuration Reference Script: Chart'
Then just replace the default code by the code below.
Check the razor syntax, and try to convert your report.
Code:

@using Winnovative.ExcelLib
@using SealExcelConverter
@{	
	//Full documentation of the converter at http://www.winnovative-software.com/excel-library.aspx
    ExcelConverter converter = Model;
    var page = converter.Page;
    var view = converter.View;

    //Chart: rowStart and colStart can be modified here to set an absolute or relative position of the items displayed...
    int rowStart = converter.CurrentRow;
    int colStart = converter.CurrentCol;
    //Target sheet can be changed here
    var currentSheet = converter.Sheet;
	//converter.Sheet =
converter.SetAdditionalSheet(converter.Sheet.Name + " " + view.Report.Repository.TranslateReport("Charts"), ref rowStart, ref colStart);

    if (view.Model.HasSerie && view.GetBoolValue(ExcelConverter.show_charts,
true))
    {
        var firstSerie = page.Series[0];

        ExcelChartType chartType = (firstSerie.Element.SerieDefinition == Seal.Model.SerieDefinition.Serie ?
ExcelConverter.ConvertChartType(page.Series[0].Element.SerieType) :
ExcelConverter.ConvertChartType(page.Series[0].Element.Nvd3Serie));
        ExcelChart chart = converter.Sheet.Charts.AddChart(chartType,
colStart, rowStart, colStart + converter.ChartWidth, rowStart + converter.ChartHeight);
        chart.Title.Text =
view.Report.TranslateGeneral(view.GetValue(ExcelConverter.chart_nvd3_title))
;

        rowStart += converter.ChartHeight;

        //Series Y values, support only of the Primary Axis...
        int serieIndex = 1;
        int colIndex = 0;
        foreach (var serie in page.Series)
        {
            colIndex = 0;
			foreach (var xDimensionKey in
page.PrimaryXValues.Keys)
			{
				//Find the corresponding serie value...
				var value = serie.Values.FirstOrDefault(i => i.XDimensionValues == xDimensionKey);
				if (value != null) {
					converter.SetValue(rowStart +
serieIndex, colStart + colIndex, value.Yvalue);
				}
                colIndex++;
			}
			
            ExcelChartSeries chartSerie = chart.Series.AddSeries(serie.SerieDisplayName);
            chartSerie.ChartType = chartType;
            chartSerie.CategoryNamesRange = converter.Sheet[rowStart, colStart, rowStart, colStart + page.PrimaryXValues.Keys.Count - 1];
            chartSerie.ValuesRange = converter.Sheet[rowStart + serieIndex, colStart, rowStart + serieIndex, colStart + page.PrimaryXValues.Keys.Count - 1];
            serieIndex++;
        }

        //Series X Values must be set after...
        colIndex = 0;
        foreach (var xValue in page.PrimaryXValues.Keys)
        {
            converter.Sheet[rowStart, colStart + colIndex].Value = page.PrimaryXValues[xValue];
            var xCells = xValue as Seal.Model.ResultCell[];
            if (xCells != null && converter.UseElementFormat)
            {
                converter.Sheet[rowStart, colStart + colIndex].Style.Number.NumberFormatString = xCells[0].Element.GetExcelFormat(view.CultureInfo);
            }
            colIndex++;
        }

        if (converter.Sheet == currentSheet) 
        {
            converter.CurrentRow += converter.ChartHeight + serieIndex + 1;
        }
    }
    converter.Sheet = currentSheet;
}

Edited by user Tuesday, March 29, 2016 7:40:37 AM(UTC)  | Reason: Not specified

Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.