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值. 二.函数 函数:能够独立完成某项功能的模块. 函数四 ...
随机推荐
- Vue.2.0.5-条件渲染
v-if 在字符串模板中,如 Handlebars ,我们得像这样写一个条件块: <!-- Handlebars 模板 --> {{#if ok}} <h1>Yes</h ...
- nsarray排序
// // main.m // 05-数组排序 // // Created by apple on 14-3-21. // Copyright (c) 2014年 apple. All rig ...
- autorelease基本概念
// // main.m // 01-autorelease基本概念 // // Created by apple on 14-3-18. // Copyright (c) 2014年 app ...
- Virtualbox+UbuntuServer+Xshell搭建Linux开发环境
需求背景 嵌入式开发环境以编译服务器(Linux系统)为核心, 开发人员较多使用Windows系统, 通过若干工具, 可以实现开发人员使用Windows的开发工具,编写代码,然后在Linux系统上编译 ...
- 关于更新Ubuntu14.04内核后,virtualbox无法开机vm的问题
virtualbox和linux内核结合比较紧密,所以当内核意外改动,可能会引起virtualbox无法启动虚拟机,只要尝试启动虚拟机,就会弹出让你执行/etc/init.d/vboxdrv setu ...
- Silverlight动画显示Line线
目的:在silverlight中显示两点之间的连线,要求动画显示连线效果. 如果需实现动画效果不得不了解,Storyborad对象: Storyboard Silverlight 通过时间线控制动 ...
- PostgreSQL auto_explain
The auto_explain module provides a means for logging execution plans of slow statements automaticall ...
- How to create a project with existing folder of files in Visual Studio?
1. Select Visual Studio tool bar-> New -> Project from existing code-> continue with config ...
- csuoj 1329: 一行盒子
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1329 1329: 一行盒子 Time Limit: 1 Sec Memory Limit: 12 ...
- [转] linux中pam模块
一.pam简介 Linux-PAM(linux可插入认证模块)是一套共享库,使本地系统管理员可以随意选择程序的认证方式. 换句话说,不用(重新编写)重新编译一个包含PAM功能的应用程序,就可以改变它使 ...