Rank: Newbie
Groups: Registered
Joined: 12/26/2019(UTC) Posts: 6 Location: Mumbai
|
I want to write calculated values or some custom text into the excel cell. The method ExcelConverter.SetValue takes ResultCell as parameter, there is no option to write custom text.
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 12/20/2013(UTC) Posts: 1,209 Thanks: 14 times Was thanked: 206 time(s) in 199 post(s)
|
SetValue is just a helper to write and format a cell in the current sheet. You can access the excel cell with: Code:converter.Sheet.Cells[row, col].Value = 12;
check https://github.com/JanKa...i/Addressing-a-worksheetthe code of SetValue is the following: Code: public void SetValue(int row, int col, ResultCell cell)
{
string format = null;
if (cell.Element != null && !cell.Element.IsEnum && !cell.IsTitle && cell.Element.IsNumeric && UseElementFormat)
{
format = cell.Element.GetExcelFormat(View.CultureInfo);
if (cell.DoubleValue != null)
{
Sheet.Cells[row, col].Value = cell.DoubleValue.Value;
}
}
else if (cell.Element != null && !cell.Element.IsEnum && !cell.IsTitle && cell.Element.IsDateTime && UseElementFormat)
{
format = cell.Element.GetExcelFormat(View.CultureInfo);
if (cell.DateTimeValue != null)
{
Sheet.Cells[row, col].Value = cell.DateTimeValue.Value;
}
}
else
{
if (UseElementFormat)
{
Sheet.Cells[row, col].Value = cell.DisplayValue;
}
else if (cell.Value != null)
{
Sheet.Cells[row, col].Value = cell.Value.ToString();
}
}
if (UseCellStyle)
{
string style = style_cell_value;
if (cell.IsTitle) style = style_cell_title;
else if (cell.IsTotal) style = style_cell_value_total;
Sheet.Cells[row, col].StyleName = style;
}
//Apply format at the end to make it work
if (!string.IsNullOrEmpty(format))
{
Sheet.Cells[row, col].Style.Numberformat.Format = format;
}
}
|
|
|
|
Rank: Newbie
Groups: Registered
Joined: 12/26/2019(UTC) Posts: 6 Location: Mumbai
|
Thanks for quick response.
|
|
|
|
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.