none
Export data of columns to one cell in ecxel from visual studio c# RRS feed

  • Question

  • Hello, I am new to c# programming. On the part of code below I am having trouble to export the data to the same cell spited by a / on excel. I can export those data in different columns though.

    Thank you for your help!


            
        Range aRange = ws.get_Range("A2");
                Range bRange = ws.get_Range("B2");
                Range cRange = ws.get_Range("C2");
          
    
                if (aRange == null)
                {
                    Console.WriteLine("Could not get a range.");
                }
    
                Object[] args = new Object[1];
    
                aRange.GetType().InvokeMember("Value", BindingFlags.SetProperty, null, aRange, args);
                bRange.GetType().InvokeMember("Value", BindingFlags.SetProperty, null, bRange, args);
                cRange.GetType().InvokeMember("Value", BindingFlags.SetProperty, null, cRange, args);
            
    
    
                clientContext.Load(collGroup,
                    groups => groups.Include(
                        group => group.Title,
                        group => group.Id,
                        group => group.OwnerTitle);
    
                clientContext.ExecuteQuery();
                var row = 1;
                foreach (Group oGroup in collGroup)
                {
                    UserCollection collUser = oGroup.Users;
    
                    aRange.Value2 = oGroup.Title;
                    bRange.Value2 = oGroup.Id;
                    cRange.Value2 = oGroup.OwnerTitle;
                    row++;
                    ws.Cells[row, "A"] = oGroup.Title;
                    ws.Cells[row, "B"] = oGroup.Id;
                    ws.Cells[row, "C"] = oGroup.OwnerTitle;
    
                    }


    • Moved by CoolDadTx Thursday, October 8, 2015 2:13 PM Office related
    Wednesday, October 7, 2015 11:08 PM

Answers