zoukankan      html  css  js  c++  java
  • Aspose,如何用一个模板来导出到Excel

    2. Adding Worksheets to a Designer Spreadsheet

    The process of adding worksheets to a designer spreadsheet is entirely same as that of the above approach except that the Excel file is already created and we need to open that Excel file first before adding worksheet to it. A designer spreadsheet can be opened by the Workbook class.

    Example:

    [C#]
    //Creating a file stream containing the Excel file to be opened
    FileStream fstream = new FileStream("C:\\book1.xls", FileMode.Open);
    
    //Instantiating a Workbook object
    //Opening the Excel file through the file stream
    Workbook workbook = new Workbook(fstream);
    
    //Adding a new worksheet to the Workbook object
    int i = workbook.Worksheets.Add();
    
    //Obtaining the reference of the newly added worksheet by passing its sheet index
    Worksheet worksheet = workbook.Worksheets[i];
    
    //Setting the name of the newly added worksheet
    worksheet.Name = "My Worksheet";
    
    //Saving the Excel file
    workbook.Save(saveFileDialog1.FileName);
    
    //Closing the file stream to free all resources
    fstream.Close();
     

     

  • 相关阅读:
    周末单车行
    大笨
    随谈个人所得税起征点
    我的新球拍
    谈“家乐福抵制门”事件
    49届世乒赛(团体)电视转播时间表
    上海动物园拍摄记
    一个老外的故事
    请大家帮忙推荐一款名片管理软件
    不要先挂电话
  • 原文地址:https://www.cnblogs.com/MyFlora/p/2445285.html
Copyright © 2011-2022 走看看