logo

Warning: The forum is now for consultation only. Please use GitHub Discussions to post any questions or comments.


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

Notification

Icon
Error

Options
Go to last post Go to first unread
Mandar  
#1 Posted : Tuesday, January 21, 2020 11:09:23 AM(UTC)
Mandar

Rank: Newbie

Groups: Registered
Joined: 12/26/2019(UTC)
Posts: 6
India
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.
epf  
#2 Posted : Tuesday, January 21, 2020 12:56:23 PM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 1,209
Switzerland

Thanks: 14 times
Was thanked: 205 time(s) in 198 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-worksheet

the 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;
            }

        }

Mandar  
#3 Posted : Tuesday, January 21, 2020 1:02:16 PM(UTC)
Mandar

Rank: Newbie

Groups: Registered
Joined: 12/26/2019(UTC)
Posts: 6
India
Location: Mumbai

Thanks for quick response.
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.