惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
Apple Machine Learning Research
Apple Machine Learning Research
云风的 BLOG
云风的 BLOG
罗磊的独立博客
博客园 - 三生石上(FineUI控件)
量子位
GbyAI
GbyAI
腾讯CDC
T
Tailwind CSS Blog
博客园 - Franky
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
D
Docker
G
Google Developers Blog
aimingoo的专栏
aimingoo的专栏
The GitHub Blog
The GitHub Blog
Microsoft Security Blog
Microsoft Security Blog
Stack Overflow Blog
Stack Overflow Blog
Hugging Face - Blog
Hugging Face - Blog
小众软件
小众软件
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
N
Netflix TechBlog - Medium
Jina AI
Jina AI
IT之家
IT之家
Y
Y Combinator Blog

博客园 - Blue

个已实现的例子:通过Javascript在页面中直接调用Office Communicator API - Blue cmd脚本(C# 清缓存) - Blue - 博客园 isql脚本编写创建数据库(SQL Server2000) 怎样踢mstsc占用者 copy:键盘按键和键盘对应代码表 Thread简单概念 转:ListView 中添加大数据量解决屏幕刷新“闪”的现象 Regsvr32命令全攻略 一个字段存很多枚举值,然后从字段取出的方法 關於泛型的資料 索引器的两种用法 在建表时使用DEFAULT是很有用的 关于web service的验证 SQL中计算月初和月末 临时表有时很有用 在GROUP语句中还可以增加很多内容 注意insert语句写法 case的用法 尽量减少使用游标
导入导出CVS文件遇到的问题 - Blue - 博客园
Blue · 2007-07-02 · via 博客园 - Blue

1.在导出的时候,拼出cvs串:数字直接逗号分隔,字符要加引号
"\""+indexdata.DataValue.ToString()+ "\"," + "\r\n";  换行
写入文件的时候用下面的写法没问题,不然会出现:不根据逗号分开,excel打开文件串存储在一个column中。
using (StreamWriter sw = new StreamWriter(filePath))
{
sw.Write(GenerateExportString());
sw.Close();
}

2.导入写法

public DataSet ConnectCSVFile(string fileName ,string path)
{
System.Data.Odbc.OdbcDataAdapter obj_oledb_da;
DataSet ds =
new DataSet();
try
{
string strConnString="Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq="+path.Trim()+";Extensions=asc,csv,tab,txt;Persist Security Info=False";
string sql_select;
System.Data.Odbc.OdbcConnection conn; 
//Create connection to CSV file
conn = new System.Data.Odbc.OdbcConnection(strConnString.Trim());
// For creating a connection using DSN, use following line
//conn = new System.Data.Odbc.OdbcConnection(DSN="MyDSN");
//Open the connection
conn.Open();
//Fetch records from CSV
sql_select = "select * from ["+ fileName +"]";
obj_oledb_da =
new System.Data.Odbc.OdbcDataAdapter(sql_select,conn);
//Fill dataset with the records from CSV file
obj_oledb_da.Fill(ds,"dc_indexdata");
//Close Connection to CSV file
conn.Close();
}
catch(Exception er) //Error
{DcService.MessageService.ShowError(er.Message);}
return ds;
}