C#将List模型直接导出为Excel

c# 将list中的数据导出到excel #region 导入模版 另存excel /// <summary> /// 生成附件(使用Microsoft.Office.Interop.Excel组件的方式) /// </summary> /// <param name="DT"></param> 阅读详情

首先,新的一年祝大家新年快乐。
元旦也是浪了几天没怎么写东西,但必须趁着新的一年赶快开动起来

前言:

在学习了NPOI操作Excel并完成了打印报表的经历后,
个人有一些感觉,
1.用DataTable导Excel还是太麻烦
2.使用Dapper等ORM的工具,再把结果变成Datatable(个人觉得是个带壳的二维数组)和orm的概念冲突,很别扭
所有觉得有必要写个工具直接把直接把List转化为Excel,不用经过DataTable这种东西,也能和ORM一起使用,
虽然实际的开发可能因为ExceL格式的要求而使用空间不大,但总归是要有。
这个工具我已经放在码云上,地址:https://gitee.com/godenSpirit/mto-excel
代码可以在上面看,下面是我的一些总结

一.拆解泛型

在List集合中必须要指定一个泛型T,他是动态的,我要做的就是用反射分析这个T的属性,然后再做进一步的操作
好在C#的泛型比JAVA更强大,在运行时也保证其类型的确定,而不是JAVA的类型擦除(在运行时无法保证类型的确定性),
反射拿出一个类型的属性很简单,以所有属性都是基础类型的poco为例,

Type Target = typeof(T);
PropertyInfo[] pros = Target.getProperties();

再遍历属性拿出值即可

foreach(PropertyInfo pro in pros)
{
	Object obj = pro.getValue(集合的Element实例);
}

但以如此方法,拿出引用类型属性则会直接给那个对象不能进一步的打印,我使用一个自定义的Attribute来标记是否需要打印引用对象属性的具体值

    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
    public class ReferenceType : Attribute   //这个标记将属性标记为引用类型
    {
        //是否将引用类型再按属性拆分为多个列展示
        private bool isMultiColumn = true;

        public ReferenceType(bool isMultiColumn)
        {
            this.isMultiColumn = isMultiColumn;
        }

        public bool getIsMultiPart()
        {
            return this.isMultiColumn;
        }
    }

如此一来这则得到引用属性的属性值(比较套娃)则比较困难
但并不是不能获取

 list.Foreach(item=>{
 		PropertyInfo[] pros = typeof(item).getProperties();
		foreach(PropertyInfo property in pros)
		{
			if(property is 引用类型)
			{
				PropertyInfo[] innerPros = property.PropertyType.getProperties();
				foreach(PropertyInfo secProperty in innerPros)
				{
					//获取引用属性的属性值,在三层的循环中,不太好判断
					Object obj = secProperty.getValue(property.getValue(item));
				}
			}
			
			//正常写入Excel
		}

	});

二.不同的输出到Excel的方式

可以将引用类型输出成很多列,也要允许只在一个列里,
也要能让人忽略掉一些不想输出的属性,
这个则比上面更加简单一点

/// <summary>
    /// 忽略制定标记的属性值
    /// </summary>
    [AttributeUsage(AttributeTargets.Property, AllowMultiple = false,Inherited =true)]
    public class IgnoreType:Attribute
    {

        public IgnoreType()
        {

        }
    }

忽略某个属性其实就是在打印Excel的循环中跳过中间的某次循环

if (WrapperConverter.IgnoreTypePool.ContainsKey(pro.PropertyType))
{
	//一定要在循环的开头进行判断要不要忽略本次循环
		
     //如果在忽略类型中就直接Continue,开始下一轮循环
     continue;
 }

三.使用设计模式来分离关注度

虽然这个工具的代码不多,但三层循环去操作泛型,反射,标记还是有一定难度的。
使用设计模式来分散代码的功能

其中,我使用包装模式,将判断属性是否被标记的操作交给包装类,不在真正操作类上去获取标记并进行判断

/// <summary>
    /// 这是一个基本转化器的包装类,Design By Description Mode
    /// 
    /// </summary>
    public class WrapperConverter
    {
        //类型池,用来保存打了Attribute的标签的自定义类型
        public static Dictionary<Type, ReferenceType> TypePool = new Dictionary<Type, ReferenceType>();
        public static Dictionary<Type,IgnoreType> IgnoreTypePool = new Dictionary<Type, IgnoreType>();
        /// <summary>
        /// taget对象,用来具体的打表
        /// </summary>
        public BasicConverter basic = null;

        public WrapperConverter()
        {
            basic = new BasicConverter();

        }

        public IWorkbook ConvertToExcel<T>(List<T> list)
        {
            //在调target执行真正的方法之前,在此可以设置增强方法 advice method
            CheckAttribute(typeof(T));

            return basic.ConvertToExcel(list);
        }

        /// <summary>
        /// (增强方法)检查泛型类型的属性中是否带有自定义的Reference的标签--check
        /// </summary>
        /// <param name="type"></param>
        public void CheckAttribute(Type type)
        {
            PropertyInfo[] pros = type.GetProperties();

            foreach (PropertyInfo pro in pros)
            {
                //遍历获取属性中的Attribute对象
                ReferenceType refer = (ReferenceType)pro.GetCustomAttribute(typeof(ReferenceType));
                IgnoreType ignore = (IgnoreType)pro.GetCustomAttribute(typeof(IgnoreType));
                if (refer != null)
                {
                    //将打了标记的类型和标记本身放到类型池中
                    TypePool.Add(pro.PropertyType, refer);
                }
                if(ignore != null)
                {
                    IgnoreTypePool.Add(pro.PropertyType, ignore);
                }


            }
        }

        
    }

这样我就不用在检查标记了

测试:

 public class Animal
 {
     public int Id { get; set; }
     public string Name { get; set; }
     public string Category { get; set; }
     public string LivingArea { get; set; }
     public int[] testArray { get; set; }
 }
public class Person
 {
     public string id { get; set; }

     public string name { get; set; }

     [IgnoreType]
     public float tall { get; set; }

     [ReferenceType(true)]
     public Animal pet { get; set; }
 }
 static void Main(string[] args)
 {
     List<Person> list = new List<Person>()
     {
         new Person { id = "202101",name = "张三",tall = 1.7f,pet = new Animal { Id = 1,Name = "佩奇",Category="猪",LivingArea="新日暮里" } },
         new Person { id = "202102",name = "李四",tall = 1.8f,pet = new Animal { Id = 2,Name = "旺财",Category="狗",LivingArea="SomeWhere" } },
     };

     WrapperConverter wrapper = new WrapperConverter();
     //wrapper.basic = new BasicConverter();

     IWorkbook workbook = wrapper.ConvertToExcel<Person>(list);

     FileStream fileStream = new FileStream("C:/Users/ASUS/Desktop/Demo3.xls", FileMode.Create);

     workbook.Write(fileStream);

     fileStream.Close();
 }

在这里插入图片描述
最后,欢迎提出意见

C#使用NPOI将List数据导出到Excel文档 NPOI是一个开源的C#读写Excel、WORD等微软OLE2组件文档的项目。使用 NPOI 可以在没有安装 Office 或者相应环境的机器上对 WORD/EXCEL 文档进行读写。这里 阅读详情

相关推荐

C# 把list集合数据导出到excel里面(数据导出成excel)

1、不弹出excel保存提示框 2、在后台打开excel System.Reflection.Missing misValue = System.Reflection.Missing.Value; Microsoft.Office.Interop.Excel.Application xlApp = new Microsoft.Office.Interop.Excel.A...

大张伟懦弱 5724

c#使用NPOI操作List导出excel

c#实现吧List或者DataTable数据导出excel

weixin_44172770的博客 2652

利用NPOI和List泛型导出Excel

具体方法不要看,这里这是一个参考 //弹出表的保存路径 private void Output_Click_1(object sender,RoutedEventArgs e)//导出方式合为一个方法体(强制转换sender)        {            if (Grid_Center.ItemsSource != null)            {           

qwasdf_123的专栏 4358

C# list写出到Excel

问题描述:          可视化效果 Excel导出效果   解决方法: /* 引用 using System.IO; using NPOI.SS.UserModel; using NPOI.XSSF.UserModel; 数据 List&lt;string&gt; xList = new List&lt;string&gt;() { }; List&lt;int&gt; b...

cell的博客 2620

C# 实现NPOI的Excel导出

Python微信订餐小程序课程视频 https://edu.csdn.net/course/detail/36074 Python实战量化交易理财系统 https://edu.csdn.net/course/detail/35475 技术点: 1.自定义attribute属性 2.通过反射取类及其属性的attribute属性值 3.NPOI包常用属性及方法(我也仅仅知道用到过的,陌生的要么见名知意,要么百度查) 实现功能点: List类对象的模板导出,实用场景例子见最后代码块 (emm…还是比较抽象,

weixin_45566993的博客 961

将MFC List Control数据导出到Excel的详细教程

MFC List Control是一种用于显示和管理列表的控件,广泛应用于Windows应用程序中。它提供了丰富的API来处理列表项的添加、删除、排序等操作。掌握List Control的基本操作对于开发高效、友好的用户界面至关重要。组件对象模型(Component Object Model,简称COM)是微软公司开发的一种软件架构,用于实现软件组件之间的通信。COM技术允许不同语言编写的程序组件通过接口(Interface)进行交互,从而实现跨语言、跨平台的软件组件重用。

weixin_31938351的博客 1165

【.NET】C# List导出为Excel方法

/// <summary> /// list导出为Excel /// </summary> /// <param name="list"></param> /// <param name="filePath"></param> public static void DataExport<T>(List<T> list...

W's play ground 2757

C#把数据列表、集合导出到Excel表格

把数据列表、集合导出到Excel表格 应用例子:Excel.down(list.ToList(), "查询数据", "当日数据", "Id|Code,编码|name,名称,20|num,数量|CreatedTime,时间,18|cause,备注,60");

C#导出泛型List到Excel

using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Text; using JZZC863Dal; using JZZC863Dal.Model; using Excel = Microsoft.

刘晓飞 5030

C#将list和DataTable中的数据导出到Excel的功能

C#将list和DataTable中的数据导出到Excel的功能

PSIM仿真实战:反激电源从设计到调试的完整流程(附短路保护配置)

本文详细介绍了使用PSIM仿真工具进行反激电源从设计到调试的完整流程,包括变压器参数设计、功率器件选型、动态特性调试以及短路保护配置。通过实战案例和仿真技巧,帮助工程师提前暴露并解决设计中的常见问题,如负载突变、输入电压波动和短路保护失效等,显著降低硬件试错成本。

weixin_29216353的博客 249

C#从ListView导出到Excel

 ///         /// 导出到EXCEL        ///         ///         ///         private void tsExportToExcel_Click(object sender, EventArgs e)        {            SaveFileDialog dialog = new SaveFileDialog(); 

nd200642的专栏 5289

共享单车数据分析与需求预测项目

除了自行车共享系统的有趣的实际应用之外,这些系统生成的数据特征使它们成为研究的有吸引力的对象。由于这些系统在交通、环境和健康问题中的重要作用,它们引起了极大的关注。Huber 回归器:一个对异常值具有鲁棒性的模型,CV 得分为 0.4660,表明它对此数据集可能不那么有效。代码中的内容cv_score就像您正在使用的机器学习模型的成绩单。它告诉您模型的表现如何。减少异常值的影响:它还可以减少异常值的影响,因为对数转换显着缩小了数据的范围。因此,cv_score平均分数表明您的模型的预测效果如何。

极光喵的博客 2953

使用NPOI——C#和WEB API导出到Excel

目录 介绍 在我们开始旅程之前 背景 使用代码 下载示例 - 650.6 KB 介绍 本文将引导您完成通用导出到Excel功能,该功能经过试用和测试,在WEB API中使用C#并使用NPOI。 本文特定于.NET Framework,而我在.NET Core中尝试过,它运行得非常好。 在我们开始旅程之前 本文的主要概念是通过导入npoi开发通用excel来导出功能,并添加下面解释...

寒冰屋的专栏 3136

Qt Coordinate System

Qt 坐标系统Qt 坐标系统 数学基础 Qt坐标系统 视口 平移变换 缩放变换 setWindow 旋转 总结数学基础 矩阵与线性变换坐标系变换Qt坐标系统 视口和OpenGL一样,视口确定了画面在窗口(QWidget)中显示的区域,Qt的绘图坐标会完全映射到视口(View port)上,就像图示一样。默认情况下,窗口和视口是重合的,视口的大小覆盖了整个窗口。和OpenGL一样,Qt的QPa

unclerunning的博客 1155

计算机网络基础:认识网络硬件与传输介质

计算机网络基础:认识网络硬件与传输介质,在计算机网络的庞大体系中,网络硬件与传输介质犹如坚实的骨架与脉络,支撑并承载着信息的流动。从家庭中的小型网络,到企业复杂的办公网络,再到覆盖全球的互联网,各类网络硬件设备各司其职,不同的传输介质发挥着独特的传输作用。它们相互协作,使得数据能够在不同设备之间快速、准确地传输,为人们的日常沟通、工作办公、娱乐休闲等活动提供了基础保障。

不踩坑,不知道坑有多深;不总结,踩过的坑白踩。 3万+

C#导出模板Excel

根据指定的模板来导出Excel内容. 第一步 先要引用NPOI ,右键项目名称管理nuget程序包,从这里加就行,不用从网上下载,当初搞了半天一直报错,这个东西很好用 第二步 我是先把需要统计的存到List里了.bool ReportExcelForTemplate(List<StudentEntity> selist, string filepath, string templat...

weixin_44413414的博客 1535

基于XDMA 的PCIE读写DDR

基于XDMA 的PCIE读写DDR 概述:   想实现基于FPGA的PCIe通信,查阅互联网各种转载…基本都是对PCIe的描述,所以想写一下基于XDMA的PCIe通信的实现(PCIe结构仅做简单的描述(笔记),了解详细结构移至互联网)。 实现功能:PC通过PCIE读写DDR,同时用户通过逻辑代码可以读取被写入DDR内的数据(我是通过VIO实现DDR任意地址,任意数据大小的读取。)。 实践实践!!! 说明: 参考文档: PCI Express Base Specification Revision 3.0 P

Crazzy_M的博客 1万+

一、NPOI导出Excel(list导出)

NPOI导出Excel(List集合导出)

weiwei_y的博客 1739

【软考中级网络工程师】知识点之 ICMP 协议

本文聚焦软考中级网络工程师必备的 ICMP 协议知识,先概述其在 TCP/IP 协议族网络层的地位与无连接特性,再阐述差错报告、网络诊断等功能。解析报文格式,详解差错与查询类报文类型及工作机制,还介绍其在 Ping、Traceroute 命令中的应用,分析常见攻击与防范措施,最后总结核心要点,为网络工程师学习和应用 ICMP 协议提供全面指导。

邓邓子的博客 1408

RK3588部署YOLOv11与RKNN全流程教程

本文详细介绍了在RK3588开发板上部署YOLOv11目标检测模型的全流程。主要内容包括:PC端CUDA/cuDNN环境配置、Anaconda虚拟环境搭建、RKNN Toolkit2安装;YOLOv11模型从PyTorch到ONNX再到RKNN的格式转换;以及RK3588开发板的系统配置、RKNPU驱动安装和最终推理实现。教程提供了完整的代码示例,帮助开发者快速在边缘设备上实现高效的AI推理应用,涵盖从环境准备到实时检测的全套解决方案。

FJN110的博客 381

List导出数据Excel

<br /><br />using System.Collections.Generic;<br />using System.IO;<br />using System.Reflection;<br />using System.Web;<br /> <br />    /// <summary><br />            /// Excle导出数据<br />            /// </summary><br />            /// <typeparam name="T">类

windcoldice的专栏 2194

c#后台如何导出excel到本地_vue导入excel表格数据-vue 我想把前端的一个 list导出excel,后台是 c#?...

vue怎么把excel转jsona={'3:39:20'}xlswrite('a.xls',a)如果你要写到其他数据表的某个单元格可以这样:a={'3:39:20'}xlswrite('a.xls',a,'sheet2','A2')?你这个就是个时间转换问题。读取的时候自己进行了时间转换,你再转换回去就行了。[~,~,result]=xlsread('a.xls','Sheet1','A1');x...

weixin_32151313的博客 334

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

国产化Excel开发组件Spire.XLS教程:C# 写入 Excel ,轻松将数据导出到工作表

本文将系统讲解如何使用 C# 写入 Excel 文件 ,包括不同数据类型的插入方法、批量数据写入技巧、文件保存与导出,助力开发者提升数据处理与自动化能力。

开发者效率提升工具的博客 955

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

C# 将List数据写入Excel

将List中的额数据写入Excel 由于是Excel文件,所以要用到Office相关的dll,故请添加相应dll的引用,然后在程序中添加如下命名空间: using Microsoft.Office.Interop.Excel; 自定义类: public class Student { private string id; pub...

Loner_M的博客 2689

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

上一篇: NPOI的使用学习记录(一)创建Excel和写入数据
下一篇: AutoFac多个实现类中获取指定实现类的三个方法
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

罗马苏丹默罕默德

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值