Rank: Administration
Groups: Administrators
Joined: 12/20/2013(UTC) Posts: 1,209 Thanks: 14 times Was thanked: 206 time(s) in 199 post(s)
|
In addition here is a sample to add the logo and a textbox having the title in your Excel file (got from https://github.com/JanKa...es,-Pictures-and-Charts)This replaces the 'Root script: Header' Code:@using Seal.Converter
@using System.IO
@using System.Drawing
@{
//Full documentation of the EPPlus OpenXml converter at https://github.com/JanKallman/EPPlus
ExcelConverter converter = Model;
var report = converter.View.Report;
var sheet = converter.Sheet;
//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;
var styleName = ExcelConverter.style_cell_title;
var repository = converter.View.Report.Repository;
var logoPath = Path.Combine(repository.ViewImagesFolder, repository.Configuration.LogoName);
var img = Image.FromFile(logoPath);
var pic = sheet.Drawings.AddPicture("0", img);
pic.SetPosition(0, 0, 0, 0);
//Add the textbox
var shape = sheet.Drawings.AddShape("myShape", eShapeStyle.Rect);
shape.SetPosition(0, 0, 4, 0); //Position Row, RowOffsetPixels, Column, ColumnOffsetPixels
shape.SetSize(500, 20); //Size in pixels
shape.Text = report.ExecutionName;
rowStart+=3;
if (converter.ShowTitle)
{
sheet.Cells[rowStart, colStart].Value = report.ExecutionName;
sheet.Cells[rowStart, colStart].StyleName = styleName;
rowStart++;
}
if (converter.ShowMessage)
{
sheet.Cells[rowStart, colStart++].Value = report.ExecutionMessages;
rowStart++;
}
if (converter.ShowInformation)
{
sheet.Cells[rowStart, colStart++].Value = report.Translate("Model");
sheet.Cells[rowStart, colStart++].Value = report.Translate("Records");
sheet.Cells[rowStart, colStart++].Value = report.Translate("Pages");
sheet.Cells[rowStart, colStart++].Value = report.Translate("Duration");
sheet.Cells[rowStart, colStart++].Value = report.Translate("Restrictions");
sheet.Cells[rowStart, colStart - 5, rowStart, colStart].StyleName = styleName;
colStart = converter.CurrentCol;
rowStart++;
foreach (var item in report.Models.Where(i => i.ResultTable != null && i.Pages != null))
{
sheet.Cells[rowStart, colStart++].Value = item.Name + "("+ item.Connection.Name + ")";
sheet.Cells[rowStart, colStart++].Value = item.ResultTable.Rows.Count;
sheet.Cells[rowStart, colStart++].Value = item.Pages.Count;
sheet.Cells[rowStart, colStart++].Value = item.ExecutionDuration;
sheet.Cells[rowStart, colStart++].Value = item.RestrictionText;
colStart = converter.CurrentCol;
rowStart++;
}
rowStart++;
}
converter.CurrentRow = rowStart;
}
|
2 users thanked epf for this useful post.
|
|