Merging Cells in Excel using C#

后端 未结 11 1114
耶瑟儿~
耶瑟儿~ 2020-12-24 01:32

I have a database which contains 5 tables. Each table contains 24 rows and each row contains 4 columns.

I want to display these records in Excel sheet. The heading o

11条回答
  •  天涯浪人
    2020-12-24 02:11

    Excel.Application xl = new Excel.ApplicationClass();
    
    Excel.Workbook wb = xl.Workbooks.Add(Excel.XlWBATemplate.xlWBATWorkshe et);
    
    Excel.Worksheet ws = (Excel.Worksheet)wb.ActiveSheet;
    
    ws.Cells[1,1] = "Testing";
    
    Excel.Range range = ws.get_Range(ws.Cells[1,1],ws.Cells[1,2]);
    
    range.Merge(true);
    
    range.Interior.ColorIndex =36;
    
    xl.Visible =true;
    

提交回复
热议问题