【152】C# 操作 Excel 雜記

來源:互聯網
上載者:User

標籤:style   blog   http   color   ar   os   sp   div   on   

  前面寫了一篇博文是關於 C# 操作 Excel 的文章,但是裡面有些中規中矩,搞的我不知道怎麼寫了,所以另開一帖。。

2014年11月10日

  1. 引用:Microsoft.Office.Interop.Excel
  2. eWorksheet.Name:sheet的名稱修改
  3. Sheets.Add 方法 (Excel)
    參考:戳這兒!
    參考:戳這兒!
  4. 會預設有一個sheet,之後添加的sheet就是第二個
    eWorkbook.Sheet.Add(eWorksheet, nothing, nothing, nothing);    //在eWorksheet之前添加一個新sheeteWorkbook.Sheet.Add(nothing, eWorksheet, nothing, nothing);    //在eWorksheet之後添加一個新sheet

    注意:sheet的索引是從1開始的。。
    參考:戳這兒!

  5. 儲存格合并
    Excel.Range eRange = eWorksheet.get_Range("A1", "C1");eRange.MergeCells = true;eRange.Value = "還好快樂";
  6. 儲存格置中對齊
    eRange.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;
  7. 自動適應列寬
    eWorksheet.Cells.Columns.AutoFit();

    參考:戳這兒!
    參考:戳這兒!



 

【152】C# 操作 Excel 雜記

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.