最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
用C#生成Excel文件的方法和Excel.dll组件生成的方法
时间:2022-07-02 11:08:59 编辑:袖梨 来源:一聚教程网
一个示例:
class AppTest
{
private Excel.ApplicationClass _x;
public static void Main0()
{
AppTest a = new AppTest();
a._x = new Excel.ApplicationClass();
a._x.UserControl = false;
for (int i = 0 ;i < 4; i++)
{
a.SaveToXls("D:test" + i + ".xls"); // 本例是在D盘下建立的test文件夹
}
a._x.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject((object) a._x);
System.GC.Collect();
}
private void SaveToXls(string filename)
{
Excel.WorkbookClass wb = (Excel.WorkbookClass) this._x.Workbooks.Add(System.Reflection.Missing.Value);
for(int i = 1;i <= 4; i++)
{
this._x.Cells[i,1]=i.ToString();
this._x.Cells[i,2]="bbb2";
相关文章
- 博德之门3巨人投掷流构筑指南 07-01
- 比特币面临10.8万美元鲸鱼出逃——散户何去何从? 07-01
- 三千幻世强力阵容推荐指南 07-01
- 炉石传说无限开炮融合贼卡组构筑指南 07-01
- 比特币即将创下新高,山寨季会来临吗? 07-01
- Fragmetric是什么?Solana生态再质押协议背景解析 07-01