Advanced Grouping with GemBox

Crystal Rouse
Crystal Rouse used Ask the Experts™
on
I need some examples of how to do advanced grouping and formatting using GemBox and C#.
We use MVC

Thank You!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Technical Specialist
Awarded 2017
Distinguished Expert 2018
Commented:
Post some screenshot of what you would have done in Excel directly and I will do my best to assist.

I have used Gembox Sheet and Document
Crystal RouseTask Lead

Author

Commented:
I have attached my Excel Template.  I just need help getting started.  How to format and merge rows and how to loop thru records inside of the tables.  Just a snippet or two to get me started....Thanks!
Report-Template.xlsx
Shaun VermaakTechnical Specialist
Awarded 2017
Distinguished Expert 2018
Commented:
This is how I load Excel Sheet into a Turple
//Loads a dataset from Excel WorkSheet into a complex Dictionary.
private static Dictionary<Tuple<string, string>, string> LoadDataSetFromExcelWorkSheet(ExcelWorksheet SourceWorkSheet, int RowStart, int ColumnStart, int ColumnEnd, bool HasHeaders)
{
    Dictionary<Tuple<string, string>, string> returnValue = new Dictionary<Tuple<string, string>, string>();
    Dictionary<int, string> headers = new Dictionary<int, string>();

    int rowCnt = RowStart;
    while (SourceWorkSheet.Cells[rowCnt, ColumnStart].Value != null)
    {
        string rowGUID = Guid.NewGuid().ToString();
        if ((rowCnt == RowStart) && (HasHeaders))
        {
            //Load proper header names
            for (int i = ColumnStart; i <= ColumnEnd; i++)
            {
                headers.Add(i, SourceWorkSheet.Cells[rowCnt, i].Value.ToString());
            }
        }
        else
        {
            if ((rowCnt == RowStart) && (!HasHeaders))
            {
                //Load generic header names
                for (int i = ColumnStart; i <= ColumnEnd; i++)
                {
                    headers.Add(i, System.Guid.NewGuid().ToString());
                }
            }
            //Load records
            for (int i = ColumnStart; i <= ColumnEnd; i++)
            {
                string cellValue = "";
                try { cellValue = SourceWorkSheet.Cells[rowCnt, i].Value.ToString(); } catch { cellValue = ""; };
                returnValue.Add(new Tuple<string, string>(rowGUID, headers[i]), cellValue);
            }
        }

        ////Move to next row
        rowCnt++;
    }

    return returnValue;
}

Open in new window

Crystal RouseTask Lead

Author

Commented:
Thank You!  This was exactly what I needed.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial