zoukankan      html  css  js  c++  java
  • Aspose.cells 导出Excel

    //Export
    private void btnExport_Click(object sender, RoutedEventArgs e)
    {
    string strDataTime = System.DateTime.Now.ToString("yyyyMMdd_HHmmss");
    string strFileName = "buyf_Template" + strDataTime;
    
    SaveFileDialog save = new SaveFileDialog();
    save.DefaultExt = "xlsx";
    save.Filter = "Excel File|*.xlsx";
    save.FileName = strFileName;
    
    if (save.ShowDialog() == true)
    {
    //获得数据源
    DataClasses1DataContext db = new DataClasses1DataContext();
    List<TBProduct> pros = new List<TBProduct>();
    pros = (from p in db.TBProduct select p).Take(20).ToList();
    
    string strReportPath = AppDomain.CurrentDomain.BaseDirectory + @"TemplateBuyf_Template.xlsx";
    //string strReportPath = System.Windows.Forms.Application.ExecutablePath + @"TemplateBuyf_Template.xlsx";
    
    Workbook book = new Workbook(strReportPath);
    Worksheet sheet = book.Worksheets[0];
    
    sheet.Cells[0, 0].PutValue("Item One");
    sheet.Cells[0, 1].PutValue("Item Two");
    sheet.Cells[0, 2].PutValue("Item Three");
    sheet.Cells[0, 3].PutValue("Item Four");
    
    for (int i = 0; i < pros.Count; i++)
    { 
    TBProduct pro = pros[i];
    
    sheet.Cells[i + 1, 0].PutValue(pro.No);
    sheet.Cells[i + 1, 1].PutValue(pro.Name);
    sheet.Cells[i + 1, 2].PutValue(pro.CarNumber);
    sheet.Cells[i + 1, 3].PutValue(pro.SRP);
    }
    
    
    book.Save(save.FileName);
    MessageBox.Show("Export Successful!");
    }
    }
  • 相关阅读:
    Keras实例教程(2)
    Keras实例教程(1)
    tf.nn.l2_loss()的用法
    在tensorflow中使用batch normalization
    Tensorflow的LRN是怎么做的
    CNN卷积中多通道卷积的参数问题
    caffe学习网站
    交叉熵反向求导计算过程
    矩阵求导
    循环神经网络(RNN)模型与前向反向传播算法
  • 原文地址:https://www.cnblogs.com/buzi521/p/3851510.html
Copyright © 2011-2022 走看看