如何将弹性数据集写入Excel工作表? [英] How can I write flexible dataset into the excel sheet?

查看:94
本文介绍了如何将弹性数据集写入Excel工作表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据集.在此数据集中,各列是灵活的.如何将该数据集写入excel工作表?

I have a Dataset. In this Dataset the columns are flexible.How can I write this dataset into the excel sheet?

推荐答案

您只需要循环浏览每个DataRow的ItemArray ,就像这样:

You just need to cycle through the items each DataRow''s ItemArray, something like this:

Int row = 0;
DataSet ds = new DataSet();
            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                for(int i = 0; i <= dr.ItemArray.Count(); i++)
                {
                    workSheet.Cells[row, i] = dr.ItemArray[i];
                }
                row++;
            }



希望对您有帮助



Hope this helps


这篇关于如何将弹性数据集写入Excel工作表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆