bianwu 哈希表输出到 excel
一、输出到excel
函数:
protected void InputFileTheme(object[] Header,object [] DataFileds,string sql,string filename)
{
SqlDBHandler dbHandler=this.getDBHandler();
string filterStr=",";
string strTemp;
Hashtable hashTable=new Hashtable();
//hashTable.Add("laguage","513");//正文语种
/*hashTable.Add("themetype3","504");//参考地图地域类别
hashTable.Add("themetype4","505");//参考地图形式类别
hashTable.Add("themetype5","508");//基础教材性质类别
hashTable.Add("themetype6","506");//基础教材学科类别
hashTable.Add("themetype8","519");//教辅性质
//基础教材版别
hashTable.Add("usesegment","509");//基础教材使用学段
hashTable.Add("useterm","510");//基础教材使用学期
hashTable.Add("managemode","511");//编务管理类别
hashTable.Add("electype","608");//电子出版物类型 (dictid=608)
hashTable.Add("bindmode","516");//装帧形式
hashTable.Add("papersize","605");//纸张尺寸
hashTable.Add("isfund","517");//出版基金类别
*/
if(sql.Trim().Equals(""))
return;
if(DataFileds==null)
return;
if(filename.Equals(""))
filename="default";
int len;
string strInput;
StringWriter sw=new StringWriter();
//输出表头
if(Header!=null)
{
strInput="";
;len<Header.Length;len++)
{
if(Header[len]!=null)
{
if(strInput.Equals(""))
strInput=Header[len].ToString();
else
strInput+=filterStr+Header[len].ToString();
}
}//for(len=0;len<Header.Length;len++)
strInput="序号"+filterStr+strInput;
sw.WriteLine(strInput);
}//if(Header!=null)
DataTable dt=dbHandler.ExecuteDataTable(sql);
dt=CncBw.Db.ThemeInfoSet.ThemeInfoDictTransfer(dt);
;
foreach(DataRow dr in dt.Rows)
{
strInput="";
row+=;
;len<DataFileds.Length;len++)
{
)
{
//输入字段,输出数据
if(dr[DataFileds[len].ToString()]!=null)
{
strTemp=dr[DataFileds[len].ToString()].ToString().Trim();
strTemp=strTemp.Replace(",",",");
strInput=strTemp;
}
else
{
strInput="null";
}//if(dr[DataFileds[len]]!=null)
}
else
{
if(dr[DataFileds[len].ToString()]!=null)
{
strTemp=dr[DataFileds[len].ToString()].ToString().Trim();
strTemp=strTemp.Replace(",",",");
strTemp = strTemp.Replace("\r\n", " ");
strInput+=filterStr+strTemp;
}
else
strInput+=filterStr+"null";
}//if(len==0)
}//for(len=0;len<DataFileds.Length;len++)
strInput=row.ToString()+filterStr+strInput;
sw.WriteLine(strInput);
}//foreach(DataRow dr in dt.Rows)
sw.Close();
Response.AddHeader("Content-Disposition", "attachment;filename="+filename+".csv");
Response.ContentType = "application/ms-excel";
Response.ContentEncoding=System.Text.Encoding.GetEncoding("GB2312");
//Response.ContentEncoding=System.Text.Encoding.GetEncoding("unicode");
Response.Write(sw);
Response.End();
dbHandler.Close();
}
二、调用
this.InputFileTheme(header,dataFileds,strSql,"bookinfo");
bianwu 哈希表输出到 excel的更多相关文章
- arcgis api for javascript 学习(三) 调用发布地图信息,并将地图属性信息输出到Excel表中
吐血推荐:网上搜了很久关于webgis地图属性表输出到Excel表,并没能找到相关有价值的信息,在小白面前,这就是一脸懵x啊!网上要么是关于前端如何在页面上直接导出excel,和webgis半毛钱关系 ...
- 【哈希表】CodeVs1230元素查找
一.写在前面 哈希表(Hash Table),又称散列表,是一种可以快速处理插入和查询操作的数据结构.哈希表体现着函数映射的思想,它将数据与其存储位置通过某种函数联系起来,其在查询时的高效性也体现在这 ...
- openssl lhash 数据结构哈希表
哈希表是一种数据结构,通过在记录的存储位置和它的关键字之间建立确定的对应关系,来快速查询表中的数据: openssl lhash.h 为我们提供了哈希表OPENSSL_LHASH 的相关接口,我们可以 ...
- hdu acm 1425 sort(哈希表思想)
sort Time Limit: 6000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submis ...
- noip模拟赛 好元素 哈希表的第一题
这是一道关于 题2好元素 2s [问题描述] 小A一直认为,如果在一个由N个整数组成的数列{An}中,存在以下情况: Am+An+Ap = Ai (1 <= m, n, p < i < ...
- [转]net中哈希表的使用 Hashtable
本文转自:http://www.cnblogs.com/gsk99/archive/2011/08/28/2155988.html 以下是PetShop中DBHelper中的使用过程: //创建哈希表 ...
- Snowflake Snow Snowflakes(哈希表的应用)
Snowflake Snow Snowflakes Time Limit: 4000MS Memory Limit: 65536K Total Submissions: 27312 Accep ...
- 索引器、哈希表Hashtabl、字典Dictionary(转)
一.索引器 索引器类似于属性,不同之处在于它们的get访问器采用参数.要声明类或结构上的索引器,使用this关键字. 示例: 索引器示例代码 /// <summary> /// 存储星 ...
- c# 哈希表跟函数
一.哈希表集合 先进后出,一个一个赋值,但只能一起取值. 1.哈希表的建立.赋值以及读取. 2.利用枚举类型打印出集合中的Key值和Value值. 二.函数 函数:能够独立完成某项功能的模块. 函数四 ...
随机推荐
- Django 学习
urls.py 路由系统 from django.conf.urls import url,includefrom django.contrib import adminfrom web import ...
- hive DDL
官网地址:https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL https://cwiki.apache.org/co ...
- 启动MFC程序的时候报错:0xC0000005: 读取位置 0x00000000 时发生访问冲突
此程序的结构是 MouseCap.h #pragma once #include <afxwin.h> class MouseCapApp : public CWinApp { publi ...
- iOS添加自动更新的代码
- (void)versionUpdate{ //获得当前发布的版本 dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_ ...
- system(linux) power on note
读詹荣开文档摘 BIOS 在完成硬件检测和资源分配后,将硬盘 MBR 中的 Boot Loader 读到系统的 RAM 中,然后将控制权交给 OS Boot Loader Boot Loader执行全 ...
- c# 工具
虚拟机 http://sandcastle.codeplex.com/ 读取excel等的一个工具 http://npoi.codeplex.com/releases/view/115353 host ...
- devexpress13学习系列(四)PDFViewer(4)
PdfViewer的属性: CurrentPageNumber:显示当前页的页码. DocumentFilePath:当前文件. DocumentProperties:文件属性. PageCount: ...
- Leetcode: Palindrome Pairs
Given a list of unique words, find all pairs of distinct indices (i, j) in the given list, so that t ...
- BCB 多线程的同步与协调
多线程编程是提高系统资源利用率的一种常见方式.它占用的资源更小,启动更快,还可以实现在后台运行一些需时较长的操作.[喝小酒的网摘]http://blog.hehehehehe.cn/a/8498.ht ...
- UVa 10007 - Count the Trees(卡特兰数+阶乘+大数)
题目链接:UVa 10007 题意:统计n个节点的二叉树的个数 1个节点形成的二叉树的形状个数为:1 2个节点形成的二叉树的形状个数为:2 3个节点形成的二叉树的形状个数为:5 4个节点形成的二叉树的 ...