Copy codeThe Code is as follows:/Read temporary files
GYYW. DA. Common. Base_SqlDataBase daBZDM = new GYYW. DA. Common. Base_SqlDataBase ();
DataSet dsBZDM = daBZDM. GetDataSetBySql ("select QCDM, MC, GG from WG_BZDM where QCDM like '200 '");
// Use the Data in the virtual directory as the temporary file directory.
String urlPath = HttpContext. Current. Request. ApplicationPath + "/
// Read temporary filesGYYW. DA. Common. Base_SqlDataBase daBZDM = new GYYW. DA. Common. Base_SqlDataBase ();DataSet dsBZDM = daBZDM. GetDataSetBySql ("select QCDM, MC, GG from WG_BZDM where QCDM like '200 '");
// Use the Data in the virtual directory as the temporary file directory.String urlPath = HttpContext. Current. Request. ApplicationPath + "/Data /";Strin
Copy codeThe Code is as follows:/read temporary files
GYYW. DA. Common. Base_SqlDataBase daBZDM = new GYYW. DA. Common. Base_SqlDataBase ();
DataSet dsBZDM = daBZDM. GetDataSetBySql ("select QCDM, MC, GG from WG_BZDM where QCDM like '200 '");
// Use the Data in the virtual directory as the temporary file directory.
String urlPath = HttpContext. Current. Request. ApplicationPath + "/
Export dataset to excel and dataset to excel
I found a lot of such code on the Internet. If it weren't for Chinese garbled characters, it would be too complicated. This is the best one I have ever used.
// Ds is the data source, filename is the saved file name publicvoidCr
/// /// Export an Excel worksheet to import multiple datatables of a dataset to multiple sheets of an Excel worksheet.
/// /// /// /// Public void doexport (Dataset ds, string [] tablenames, string strexcelfilename)
{
Microsoft. Office. InterOP. Excel. Application
Label: blog HTTP ar SP data Div on 2014 Toxy是继NPOI之后主推的另一个项目,主要目的是为了解决文档的抽取问题,其支持的格式包括所有docx、xlsx、xls、csv、vcard等。下面是一个简单但很有用的例子 ParserContext c=new ParserContext(@"d:\demo.xls");var parser=ParserFactory.CreateSpreadsheet(c);var spreadsheet= parser.Parse();DataSet ds = spreadsheet.ToDataSet();这里就是传说中可以直接把Excel Workbook转换成
Http://hi.baidu.com/smalltube/blog/item/58640e771d5caf1fb151b958.html
According to some information on the Internet, I wrote two classes to convert dataset and excel.
The Excel COM control must be introduced before use ..
Using system;Using system. Data;Using Excel;
Namesp
Toxyis the followingNpoiThe main purpose of this project is to solve the problem of extracting documents. Its supported formats include alldocx,xlsx,xls,CSV,vcardand so on. here is a simple but very practical example ParserContext c=new ParserContext (@ "D:\demo.xls"); var parser=parserfactory.createspreadsheet (c); var spreadsheet= Parser. Parse ();D ataset ds = spreadsheet. Todataset ();This is the legend that can directlyExcel Workbookconverted intoDataSetthe code, fantastic bar!he
TryTen { One da. Fill (DS); A } - Catch(Exception ex) - { the Throw NewException ("failed to read Excel:"+Ex. Message); - } - returnds; -}View CodeException handling:1. If the External table is not in the expected format appears.Most of this is due to the fact that OLE DB or extended properties in the path do not correspond to the current version of th
classImport {/// ///import Excel into the dataset/// /// the file's path and full file name, with extension /// PublicDataSet Exceltodataset (stringstrfilesourse) {DataSet DS=NewDataSet (); //Excel Data source (compatible with 03/10)
A while ago, a classmate asked me to analyze two data and a section of Dephi code, he himself has initially implemented the export from the dataset to Excel, but did not implement the line break and the occurrence of the other columns except the first column are missing a row of records. So hopefully I can help. An algorithm that imports multiple product encoding
Copy Code code as follows:
/Read Temporary files
GYYW.DA.Common.Base_SqlDataBase DABZDM = new GYYW.DA.Common.Base_SqlDataBase ();
DataSet DSBZDM = Dabzdm.getdatasetbysql ("Select Qcdm,mc,gg from WG_BZDM where QCDM like ' 2% '");
The data in the virtual directory is also used as the temporary file directory.
String URLPath = HttpContext.Current.Request.ApplicationPath + "/
My friend asked me to write the program that just solved the import problem yesterday and completed filtering, sorting, adding, deleting, searching, replacement, and so on. Now I want to export the program. Users can answer and query the information to export the data:
The Code is as follows:
You must first reference the Excel component.
Here, mydata is my dataset
DataSet exported to excel in C #
cn = New Adodb.connectionstr = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" Me.ofdselectexcel.filename "Extended properties=" " Excel 8.0;hdr=yes "" "Cn.open (str)' Get the name of all sheetCbsheet.properties.items.clear ()Dim rs1 As New Adodb.recordsetRs1 = Cn.openschema (adod
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.