.net导出到excel的多种方法汇总

Qt绘图库对决:QWT与QCustomPlot的实战选型指南 本文为Qt开发者提供了QWT与QCustomPlot两大绘图库的实战选型指南。文章从功能特性、性能资源、开发效率三大维度进行深度对比,并结合工业监控、科学计算、嵌入式设备等典型场景,给出了清晰的决策清单。对于需要专业科学图表(如极坐标、等高线图)的场景推荐QWT;对于追求高性能、实时性、快速开发及嵌入式部署的通用图表需求,QCustomPlot是更优选择。 阅读详情

1、由dataset生成

public void CreateExcel(DataSet ds,string typeid,string FileName) 
  {
   HttpResponse resp;
   resp = Page.Response;
   resp.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
   resp.AppendHeader("Content-Disposition", "attachment;filename=" + FileName);   
   string colHeaders= "", ls_item="";
   int i=0;
 
   //定义表对象与行对像,同时用DataSet对其值进行初始化
   DataTable dt=ds.Tables[0];
   DataRow[] myRow=dt.Select(""); 
   // typeid=="1"时导出为EXCEL格式文件;typeid=="2"时导出为XML格式文件
   if(typeid=="1")
   {
    //取得数据表各列标题,各标题之间以\t分割,最后一个列标题后加回车符
    for(i=0;i     colHeaders+=dt.Columns[i].Caption.ToString()+"\t";
    colHeaders +=dt.Columns[i].Caption.ToString() +"\n";   
    //向HTTP输出流中写入取得的数据信息
    resp.Write(colHeaders); 
    //逐行处理数据  
    foreach(DataRow row in myRow)
    {
     //在当前行中,逐列获得数据,数据之间以\t分割,结束时加回车符\n
     for(i=0;i      ls_item +=row[i].ToString() + "\t";     
     ls_item += row[i].ToString() +"\n";
     //当前行数据写入HTTP输出流,并且置空ls_item以便下行数据    
     resp.Write(ls_item);
     ls_item="";
    }
   }
   else
   {
    if(typeid=="2")
    { 
     //从DataSet中直接导出XML数据并且写到HTTP输出流中
     resp.Write(ds.GetXml());
    }    
   }
   //写缓冲区中的数据到HTTP头文件中
   resp.End();
 
 
  }
2、由datagrid生成

public void ToExcel(System.Web.UI.Control ctl)  
  {
   HttpContext.Current.Response.AppendHeader("Content-Disposition","attachment;filename=Excel.xls");
   HttpContext.Current.Response.Charset ="UTF-8";    
   HttpContext.Current.Response.ContentEncoding =System.Text.Encoding.Default;
   HttpContext.Current.Response.ContentType ="application/ms-excel";//image/JPEG;text/HTML;image/GIF;vnd.ms-excel/msword
   ctl.Page.EnableViewState =false;   
   System.IO.StringWriter  tw = new System.IO.StringWriter() ;
   System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter (tw);
   ctl.RenderControl(hw);
   HttpContext.Current.Response.Write(tw.ToString());
   HttpContext.Current.Response.End();
  }
 
用法:ToExcel(datagrid1);
 

3、这个用dataview

public void OutputExcel(DataView dv,string str)
{
   //
   // TODO: 在此处添加构造函数逻辑
   //
                           //dv为要输出到Excel的数据,str为标题名称
   GC.Collect();
   Application excel;// = new Application();
   int rowIndex=4;
   int colIndex=1;
 
   _Workbook xBk;
   _Worksheet xSt;
 
   excel= new ApplicationClass();
  
   xBk = excel.Workbooks.Add(true);
   
   xSt = (_Worksheet)xBk.ActiveSheet;
 
   //
   //取得标题
   //
   foreach(DataColumn col in dv.Table.Columns)
   {
    colIndex++;
    excel.Cells[4,colIndex] = col.ColumnName;
    xSt.get_Range(excel.Cells[4,colIndex],excel.Cells[4,colIndex]).HorizontalAlignment = XlVAlign.xlVAlignCenter;//设置标题格式为居中对齐
   }
 
   //
   //取得表格中的数据
   //
   foreach(DataRowView row in dv)
   {
    rowIndex ++;
    colIndex = 1;
    foreach(DataColumn col in dv.Table.Columns)
    {
     colIndex ++;
     if(col.DataType == System.Type.GetType("System.DateTime"))
     {
      excel.Cells[rowIndex,colIndex] = (Convert.ToDateTime(row[col.ColumnName].ToString())).ToString("yyyy-MM-dd");
      xSt.get_Range(excel.Cells[rowIndex,colIndex],excel.Cells[rowIndex,colIndex]).HorizontalAlignment = XlVAlign.xlVAlignCenter;//设置日期型的字段格式为居中对齐
     }
     else
      if(col.DataType == System.Type.GetType("System.String"))
     {
      excel.Cells[rowIndex,colIndex] = "'"+row[col.ColumnName].ToString();
      xSt.get_Range(excel.Cells[rowIndex,colIndex],excel.Cells[rowIndex,colIndex]).HorizontalAlignment = XlVAlign.xlVAlignCenter;//设置字符型的字段格式为居中对齐
     }
     else
     {
      excel.Cells[rowIndex,colIndex] = row[col.ColumnName].ToString();
     }
    }
   }
   //
   //加载一个合计行
   //
   int rowSum = rowIndex + 1;
   int colSum = 2;
   excel.Cells[rowSum,2] = "合计";
   xSt.get_Range(excel.Cells[rowSum,2],excel.Cells[rowSum,2]).HorizontalAlignment = XlHAlign.xlHAlignCenter;
   //
   //设置选中的部分的颜色
   //
   xSt.get_Range(excel.Cells[rowSum,colSum],excel.Cells[rowSum,colIndex]).Select();
   xSt.get_Range(excel.Cells[rowSum,colSum],excel.Cells[rowSum,colIndex]).Interior.ColorIndex = 19;//设置为浅黄色,共计有56种
   //
   //取得整个报表的标题
   //
   excel.Cells[2,2] = str;
   //
   //设置整个报表的标题格式
   //
   xSt.get_Range(excel.Cells[2,2],excel.Cells[2,2]).Font.Bold = true;
   xSt.get_Range(excel.Cells[2,2],excel.Cells[2,2]).Font.Size = 22;
   //
   //设置报表表格为最适应宽度
   //
   xSt.get_Range(excel.Cells[4,2],excel.Cells[rowSum,colIndex]).Select();
   xSt.get_Range(excel.Cells[4,2],excel.Cells[rowSum,colIndex]).Columns.AutoFit();
   //
   //设置整个报表的标题为跨列居中
   //
   xSt.get_Range(excel.Cells[2,2],excel.Cells[2,colIndex]).Select();
   xSt.get_Range(excel.Cells[2,2],excel.Cells[2,colIndex]).HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection;
   //
   //绘制边框
   //
   xSt.get_Range(excel.Cells[4,2],excel.Cells[rowSum,colIndex]).Borders.LineStyle = 1;
   xSt.get_Range(excel.Cells[4,2],excel.Cells[rowSum,2]).Borders[XlBordersIndex.xlEdgeLeft].Weight = XlBorderWeight.xlThick;//设置左边线加粗
   xSt.get_Range(excel.Cells[4,2],excel.Cells[4,colIndex]).Borders[XlBordersIndex.xlEdgeTop].Weight = XlBorderWeight.xlThick;//设置上边线加粗
   xSt.get_Range(excel.Cells[4,colIndex],excel.Cells[rowSum,colIndex]).Borders[XlBordersIndex.xlEdgeRight].Weight = XlBorderWeight.xlThick;//设置右边线加粗
   xSt.get_Range(excel.Cells[rowSum,2],excel.Cells[rowSum,colIndex]).Borders[XlBordersIndex.xlEdgeBottom].Weight = XlBorderWeight.xlThick;//设置下边线加粗
   //
   //显示效果
   //
   excel.Visible=true;
 
   //xSt.Export(Server.MapPath(".")+"\\"+this.xlfile.Text+".xls",SheetExportActionEnum.ssExportActionNone,Microsoft.Office.Interop.OWC.SheetExportFormat.ssExportHTML);
   xBk.SaveCopyAs(Server.MapPath(".")+"\\"+this.xlfile.Text+".xls");
 
   ds = null;
            xBk.Close(false, null,null);
   
            excel.Quit();
            System.Runtime.InteropServices.Marshal.ReleaseComObject(xBk);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(excel);
    System.Runtime.InteropServices.Marshal.ReleaseComObject(xSt);
            xBk = null;
            excel = null;
   xSt = null;
            GC.Collect();
   string path = Server.MapPath(this.xlfile.Text+".xls");
 
   System.IO.FileInfo file = new System.IO.FileInfo(path);
   Response.Clear();
   Response.Charset="GB2312";
   Response.ContentEncoding=System.Text.Encoding.UTF8;
   // 添加头信息,为"文件下载/另存为"对话框指定默认文件名
   Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(file.Name));
   // 添加头信息,指定文件大小,让浏览器能够显示下载进度
   Response.AddHeader("Content-Length", file.Length.ToString());
   
   // 指定返回的是一个不能被客户端读取的流,必须被下载
   Response.ContentType = "application/ms-excel";
   
   // 把文件流发送到客户端
   Response.WriteFile(file.FullName);
   // 停止页面的执行
  
   Response.End();
}

、、、、、、、、、、、、、、、、、、、、、、、、、、、、

据我现在所知excel有四种方法:
1.自己写的excel接口,客户端不需要装excel,见灵感之源的blog:
http://www.cnblogs.com/unruledboy/archive/2004/07/07/22093.aspx

2.把web上的DataGrid直接导入到excel
public void ExportToExcel(System.Web.UI.Control ctl)
        {
            bool CurrCtlVisible=ctl.Visible;
            ctl.Visible=true;        Response.AppendHeader("Content-Disposition","attachment;filename=Excel.xls"); 
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
            Response.ContentType = "application/ms-excel";
            ctl.Page.EnableViewState = false;
            System.IO.StringWriter tw = new System.IO.StringWriter();
            System.Web.UI.HtmlTextWriter hw = new HtmlTextWriter(tw);
            ctl.RenderControl(hw);
            Response.Write(tw.ToString());
            Response.End();
           
            ctl.Page.EnableViewState = true;
            ctl.Visible=CurrCtlVisible;
        }
3.在引用里调用Microsoft.Office.Interop.Excel.dll,原理是把数据存到DataTable、DataView或DataGrid中,然后再把数据一格一格的赋到excel的cell里去。
见如下代码:

public class ExportToExcel
    {

        私有成员#region 私有成员
        // 数据的DataView
        private DataView dv=null;

        // 表格标题
        private string title=null;

        // 输出文件路径
        private string outFilePath=null;

 
        // 输入文件名
        private string inputFilePath=System.Windows.Forms.Application.StartupPath+@" emplate.xls";

        #endregion

        公共属性#region 公共属性
        /**//// <summary>
        /// 数据的DataView
        /// </summary>
        public DataView DV
        {
            set
            {
                dv=value;
            }
        }

        /**//// <summary>
        /// 表格标题
        /// </summary>
        public string Title
        {
            set
            {
                title=value;
            }
            get
            {
                return title;
            }
        }

        /**//// <summary>
        /// 输出文件路径
        /// </summary>
        public string OutFilePath
        {
            set
            {
                outFilePath=value;
            }
            get
            {
                return outFilePath;
            }
        }

        /**//// <summary>
        /// 输入文件路径
        /// </summary>
        private string InputFilePath
        {
            set
            {
                inputFilePath=value;
            }
            get
            {
                return inputFilePath;
            }
        }

        #endregion      

        构造函数#region 构造函数

        public ExportToExcel()
        {
        }

//        public OutputExcel(DataView dv,string title)
//        {
//
//        }

        #endregion

        公共方法#region 公共方法
        /**///
        public void CreateExcel()
        {
            int rowIndex=4;//行起始坐标
            int colIndex=1;//列起始坐标

            ApplicationClass myApp=null;
            Workbook myBook=null;
            Worksheet mySheet=null;

            //如果文件不存在,则将模板文件拷贝一份作为输出文件
            if(!File.Exists(outFilePath))
            {
                File.Copy(inputFilePath,outFilePath,true);
            }

            myApp= new ApplicationClass();
            myApp.Visible=false;
            object oMissiong=System.Reflection.Missing.Value;
            myApp.Workbooks.Open(outFilePath,oMissiong,oMissiong,oMissiong,oMissiong,
                oMissiong,oMissiong,oMissiong,oMissiong,oMissiong,oMissiong,oMissiong,
                oMissiong,oMissiong,oMissiong);
            myBook=myApp.Workbooks[1];
            mySheet=(Worksheet)myBook.ActiveSheet;

            //取得标题
            foreach(DataColumn col in dv.Table.Columns)
            {
                colIndex++;
                mySheet.Cells[4,colIndex] = col.ColumnName;
                mySheet.get_Range(mySheet.Cells[4,colIndex],mySheet.Cells[4,colIndex]).HorizontalAlignment = XlVAlign.xlVAlignCenter;//设置标题格式为居中对齐
            }

            //取得表格中的数据
            foreach(DataRowView row in dv)
            {
                rowIndex ++;
                colIndex = 1;
                foreach(DataColumn col in dv.Table.Columns)
                {
                    colIndex ++;
                    if(col.DataType == System.Type.GetType("System.DateTime"))
                    {
                        mySheet.Cells[rowIndex,colIndex] = (Convert.ToDateTime(row[col.ColumnName].ToString())).ToString("yyyy-MM-dd");
                        mySheet.get_Range(mySheet.Cells[rowIndex,colIndex],mySheet.Cells[rowIndex,colIndex]).HorizontalAlignment = XlVAlign.xlVAlignCenter;//设置日期型的字段格式为居中对齐
                    }
                    else  if(col.DataType == System.Type.GetType("System.String"))
                    {
                        mySheet.Cells[rowIndex,colIndex] = "'"+row[col.ColumnName].ToString();
                        mySheet.get_Range(mySheet.Cells[rowIndex,colIndex],mySheet.Cells[rowIndex,colIndex]).HorizontalAlignment = XlVAlign.xlVAlignCenter;//设置字符型的字段格式为居中对齐
                    }
                    else
                    {
                        mySheet.Cells[rowIndex,colIndex] = row[col.ColumnName].ToString();
                    }
                }
            }

            //加载一个合计行
            int rowSum = rowIndex + 1;
            int colSum = 2;
            mySheet.Cells[rowSum,2] = "合计";
            mySheet.get_Range(mySheet.Cells[rowSum,2],mySheet.Cells[rowSum,2]).HorizontalAlignment = XlHAlign.xlHAlignCenter;

            //设置选中的部分的颜色
            mySheet.get_Range(mySheet.Cells[rowSum,colSum],mySheet.Cells[rowSum,colIndex]).Select();
            mySheet.get_Range(mySheet.Cells[rowSum,colSum],mySheet.Cells[rowSum,colIndex]).Interior.ColorIndex = 19;//设置为浅黄色,共计有56种

            //取得整个报表的标题
            mySheet.Cells[2,2] = title;

            //设置整个报表的标题格式
            mySheet.get_Range(mySheet.Cells[2,2],mySheet.Cells[2,2]).Font.Bold = true;
            mySheet.get_Range(mySheet.Cells[2,2],mySheet.Cells[2,2]).Font.Size = 22;

            //设置报表表格为最适应宽度
            mySheet.get_Range(mySheet.Cells[4,2],mySheet.Cells[rowSum,colIndex]).Select();
            mySheet.get_Range(mySheet.Cells[4,2],mySheet.Cells[rowSum,colIndex]).Columns.AutoFit();

            //设置整个报表的标题为跨列居中
            mySheet.get_Range(mySheet.Cells[2,2],mySheet.Cells[2,colIndex]).Select();
            mySheet.get_Range(mySheet.Cells[2,2],mySheet.Cells[2,colIndex]).HorizontalAlignment = XlHAlign.xlHAlignCenterAcrossSelection;

            //绘制边框
            mySheet.get_Range(mySheet.Cells[4,2],mySheet.Cells[rowSum,colIndex]).Borders.LineStyle = 1;
            mySheet.get_Range(mySheet.Cells[4,2],mySheet.Cells[rowSum,2]).Borders[XlBordersIndex.xlEdgeLeft].Weight = XlBorderWeight.xlThick;//设置左边线加粗
            mySheet.get_Range(mySheet.Cells[4,2],mySheet.Cells[4,colIndex]).Borders[XlBordersIndex.xlEdgeTop].Weight = XlBorderWeight.xlThick;//设置上边线加粗
            mySheet.get_Range(mySheet.Cells[4,colIndex],mySheet.Cells[rowSum,colIndex]).Borders[XlBordersIndex.xlEdgeRight].Weight = XlBorderWeight.xlThick;//设置右边线加粗
            mySheet.get_Range(mySheet.Cells[rowSum,2],mySheet.Cells[rowSum,colIndex]).Borders[XlBordersIndex.xlEdgeBottom].Weight = XlBorderWeight.xlThick;//设置下边线加粗
            myBook.Save();
            myBook.Close( true,outFilePath,true);

            System.Runtime.InteropServices.Marshal.ReleaseComObject(mySheet);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(myBook);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(myApp);

            myApp.Quit();
            GC.Collect();
        }
        #endregion

       
    }
4.另外,这就是另外一种方法了,建一个SqlServer的数据源,利用Excel的外部数据源让Excel自己从数据库取数据:

public void ExportToExcel(string pstrSql)
        {
            Excel.Application pApplication;
            Excel._Workbook xBk;
            Excel._Worksheet xSt;
            Excel._QueryTable xQt;
            string ExcelConn = "ODBC;DRIVER=SQL Server;SERVER=localhost;UID=sa;PWD=;APP=Microsoft(R) Windows (R) 2000 Operating System;WSID=me;DATABASE=pubs";
            pApplication = new Excel.ApplicationClass();
            xBk = pApplication.Workbooks.Add(true);
            xSt = (Excel._Worksheet)xBk.ActiveSheet;
            pApplication.Cells[2,2] = this.title;

            xSt.get_Range(pApplication.Cells[2,2],pApplication.Cells[2,2]).Font.Bold = true;
            xSt.get_Range(pApplication.Cells[2,2],pApplication.Cells[2,2]).Font.Name = "黑体";
            xSt.get_Range(pApplication.Cells[2,2],pApplication.Cells[2,2]).Font.Size = 22;
            xQt = xSt.QueryTables.Add(ExcelConn,xSt.get_Range(pApplication.Cells[4,2],pApplication.Cells[4,2]),pstrSql);
            xQt.Name = "导出EXCEL";
            xQt.FieldNames = true;
            xQt.RowNumbers = false;
            xQt.FillAdjacentFormulas = false;
            xQt.PreserveFormatting = false;
            xQt.BackgroundQuery = true;
            xQt.RefreshStyle = Excel.XlCellInsertionMode.xlInsertDeleteCells;
            xQt.AdjustColumnWidth = true;
            xQt.RefreshPeriod = 0;
            xQt.PreserveColumnInfo = true;
            xQt.Refresh(xQt.BackgroundQuery);
            pApplication.Visible = true;
        }
这里的pstrSql指的是sql语句。

 

 

以下是一个拼写SQL语句的示例:

 protected void ExportToExcel(string pstrSql, string ls_value)
    {

 pstrSql = "SELECT dbo.cus_info.cus_serial , dbo.client_contact.cc_contact_ename AS 联系人英文名称, dbo.client_contact.cc_eadd_line1 AS 联系人英文地址, "
                  + "dbo.client_contact.cc_type AS 职务, dbo.client_contact.cc_meetingdate AS 会见时间, dbo.client_contact.cc_cdep AS 部门, dbo.cus_country.ctry_cname AS 国家, "
                  + "dbo.client_contact.cc_fax_law AS 传真, dbo.client_contact.cc_phone AS 电话 "
                  + "FROM dbo.cus_info INNER JOIN dbo.client_contact ON dbo.cus_info.cus_id = dbo.client_contact.cus_id INNER JOIN dbo.cus_country ON dbo.client_contact.ctry_id = dbo.cus_country.ctry_id "
                  + "WHERE (dbo.client_contact.cc_type <> 'Default') AND (dbo.cus_info.cus_serial in (" + ls_value + "))";

}

【CANoe16安装教程】亲测安装成功 CANoe16安装教程 阅读详情

相关推荐

NPOI实现.NET环境下的Excel数据导入导出详解

在信息技术飞速发展的今天,处理Excel文件已成为企业日常工作的必要环节。.NET环境下的开发者在进行此类工作时往往会选择NPOI库。NPOI是.NET平台下对Microsoft Office格式文件进行读写的一个开源库,它提供了一套全面的操作接口,使得开发者无需借助Microsoft Office的COM组件,就能直接在.NET应用程序中对Excel文件进行创建、读取、修改和写入操作。导入Excel文件的过程通常涉及以下步骤:使用NPOI读取Excel文件流。

weixin_33375360的博客 1169

.netdataset)输出流导出excel

.netdataset)输出流导出excel(无需生成模版excel文件,直接输出数据流导出excel表格)

.Net MVC NPOI 返回内存流导出Excel

适用于asp.net MVC中导出Excel,程序使用NPOI,并以内存流的方式提交到界面上,点击下载Excel

python 检查英文文章内的单词数量

参考http://blog.csdn.net/yidangui/article/details/8548511 直接发代码 # -*- coding: utf-8 -*- import os,sys info = os.getcwd() #获取当前文件名称 fin = open(u'谷歌C++编程代码规范.txt') info = fin.read() alist = i

watsy 6321

.NET导出Excel的四种方法及评测

.NET导出Excel的四种方法及评测 导出Excel.NET的常见需求,开源社区、市场上,都提供了不少各式各样的Excel操作相关包。本文,我将使用NPOI、EPPlus、OpenXML、Aspose.Cells四个市面上常见的库,各完成一个导出Excel示例。然后对其代码风格和性能做一个横向比较。最后我将说出我自己的感想。 文中所有的示例代码可以在这里下载: https://git...

weixin_30335353的博客 1746

.Net导出Excel(二)

目的 网页上的数据导出有很多种导出方法,其中有的是真正格式的Excel,也有XML文档格式的Excel,还有table格式的。真正导出Excel格式的打开是没有任何问题,...

weixin_33826268的博客 168

【Unity细节】Default clip could not be found in attached animations list.(动画机报错)

Default clip could not be found in attached animations list.和 The AnimationClip 'SkyThorm' used by the Animation component 'smashing_spikes(Clone)' must be marked as Legacy.

秩沅 1987

kinect+unity 碰撞播放动画实现:Default clip could not be found in attached animations list. animations报错解决方案

kinect+unity 碰撞播放动画实现: 目录 kinect+unity 碰撞播放动画实现: Default clip could not be found in attached animations list. animations报错解决方案 使用软件为kinectV2+unity2020:经过系列改包后,准备作一个相关kinect开发项目,所使用的是网上所流传的经典卡耐基梅隆kinect交互包里面的碰撞demo。 模型相关设置:包围盒、刚体和带有动画的fbx文件。 2.

qq_43801336的博客 2857

Default clip could not be found in attached animations list.Unity3d解决办法

在U3D中调用在3DMAX中制作的动画,系统运行时报错“Default clip could not be found in attached animations list.

IT深耕十余载,大道之简 1万+

.NET Core使用NPOI导出复杂,美观的Excel详解

这段时间一直专注于数据报表的开发,当然涉及到相关报表的开发数据导出肯定是一个不可避免的问题啦。客户要求要导出优雅,美观的Excel文档格式的来展示数据,当时的第一想法就是使用NPOI开源库来做数据导出Excel文档(当时想想真香,网上随便搜一搜教程一大堆),但是当自己真正的实践起来才知道原来想要给不同的单元格设置相关的字体样式、边框样式以及单元格样式一个简单的样式需要写这么多行代码来实现。

专注于C#/.NET/.NET Core学习、工作、面试干货和实战教程分享。这里聚焦了大量的C#/.NET/.NET Core优质文章、开源项目、实用工具和学习、工作、面试心得。 3481

.Net NPOI Excel 导出

最终效果图环境:Revit,WPF,NPOI 2.5.6,.Net Framework 4.7.2。

2301_78287784的博客 3621

C#.net导出标准的Excel(npoi)

不管用哪一种语言开发应用程序,导出功能是最常见的,一般导出文件格式最常见的有PDF 、Excel、CSV、Word、TXT等,今天我们在此介绍一下Excel导出方法。 微软提供了导出Excel多种办法,但是今天我们在这里只介绍一种第三方的导出方法,因为它简单,更多符合我们的编程习惯(个人观点),下面开始: 一、下载,官网地址:https://npoi.codeplex.c

高彬的专栏 6480

.Net Core 如何数据导出 Excel?(EPPlus->OfficeOpenXml 实现固定列和动态列导出

特别注意:本文设计的包(OfficeOpenXml.Extension.AspNetCore)依赖于 EPPlus 5.0.3 等更高版本,属于限制商业用途版本,因此只能用作个人或公司小范围内部使用。对于将数据以 Excel 表格文件输出,还是比较常用的,也存在诸多情况,比如列固定或不固定、数据类型为 List或 Json 对象等。本文通过包 OfficeOpenXml.Extension.AspNetCore 实现两个方法导出列数固定和不固定的数据。

2301_78287784的博客 1869

.Net Excel导出文件 (查询到的数据写入Excel,并导出

继续上篇小编发布的Excel导入数据而言,那么对于导出文件 他们都是常见的需求今天就将步骤以及代码奉上使用工具:Visual Studio 2022框架 .Net WebApi Core。

qq_61325957的博客 705

Python模块学习 ---- logging 日志记录(一)

  许多应用程序中都会有日志模块,用于记录系统在运行过程中的一些关键信息,以便于对系统的运行状况进行跟踪。在.NET平台中,有非常著名的第三方开源日志组件log4net,c++中,有人们熟悉的log4cpp,而在python中,我们不需要第三方的日志组件,因为它已经为我们提供了简单易用、且功能强大的日志模块:logging。logging模块支持将日志信息保存到不同的目标域中,如:保存到日志文件中

4万+

.Net/C#把数据库文件导出成为Excel/XLS文件

大家在复制方法的时候要切记,把我里面的数据库字段改成自己的,如果某个方法没有引用报错一定要引用,最主要的是字段!!!切记切记!!字段要换成自己的,方法缺少引用一定要引用否则定会报错,这是一个异步方法,也可以转换为不是异步的,可自行转换!!方法可扩展性较多,可以自己改方法只要大体逻辑不变都可运行成功!!..................

weixin_59180442的博客 1636

.NET导入导出Excel方法总结

最近,应项目的需求,需要实现Excel的导入导出功能,对于Web架构的Excel导入导出功能,比较传统的实现方式是: 1)导入Excel:将Excel文件上传到服务器的某一文件夹下,然后在服务端完成Excel的读取及数据的存储; 2)导出Excel:在服务端生成需要导出Excel,然后下载到客户端。 其中,文件的上传和下载本文不在详述,以下主要写一些DataTable或DataSet与Ex...

weixin_30947043的博客 746

.NET导出Excel文件

  最近做ASP.NET Excel导出功能,顺便整理了一下可用的一些导出Excel方法一般导出方式1,客户提出要将统计的结果导出excel文件,首先利用如下方式:   增加    %@page contentType="application/vnd.ms-excel;charset=GBK" %>头部说明,然后放一个table在该页面中即可了。2,客户看过后提

1637

.NET导出Excel

.NET导出Excel

JDBogdan的博客 375

.NET导出数据到EXCEL的几种方法探讨

最近在做一个报表系统的时候,需要把DATASET中的数据导到EXCEL当中,于是在网上找了一遍,发现了好几种方法,本来以为应该差不多,但后来经过一一试用后,发现在性能上真的差别很大,现在就介绍一下,同时有不对的希望可以指正: 1. 原理:利用office组件把dataset中的数据填充到excel文件当中。这里我不贴出全部代码了,只把关键部分贴出来:         ///  

牛牛工作室 1万+

浙江大学人工智能课程课件

浙江大学人工智能课程课件,内容有:IntroductionProblem-solving by search( 4 weeks)Uninformed Search and Informed (Heuristic) Search (1 week)Adversarial Search: Minimax Search, Evaluation Functions, Alpha-Beta Search, Stochastic SearchAdversarial Search: Multi-armed bandits, Upper Confidence Bound (UCB),Upper Confidence Bounds on Trees, Monte-Carlo Tree Search(MCTS)Statistical learning and modeling(5 weeks)Probability Theory, Model selection, The curse of Dimensionality, Decision Theory,Information TheoryProbability distribution: The Gaussian Distribution, Conditional Gaussian distributions,Marginal Gaussian distributions, Bayes’ theorem for Gaussian variables, Maximumlikelihood for the Gaussian, Mixtures of Gaussians, Nonparametric MethodsLinear model for regression: Linear basis function models; The Bias-VarianceDecompositionLinear model for classification : Basic Concepts; Discriminant Functions (nonprobabilistic methods); Probabilistic Generative Models; Probabilistic DiscriminativeModelsK-means Clustering and GMM & Expectation–Maximization (EM) algorithm, BoostingThe Course SyllabusDeep Learning(4 weeks)Stochastic Gradient Descent, BackpropagationFeedforward Neural NetworkConvolutional Neural NetworksRecurrent Neural Network (LSTM, GRU)Generative adversarial network (GAN)Deep learning in NLP (word2vec), CV(localization) and VQA(cross-media)Reinforcement learning (1weeks) Reinforcement learning: introduction

yidan_521
博客等级 码龄16年 4粉丝 1原创
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值