Import EXCEL Data to dataset, and import data to dataset
I. Prerequisites
1. micorosoft office2007
2. VS2010 and Oracle 11
Ii. Interface
3. Internal code
(1) Obtain database connections and define global variables
Private static string connString = System. Configuration. Co
Export dataset data to Excel and dataset data export
1. Write the data to the HTTP output stream/the exported data is in one row.
Public void CreateExcel (
[Size = x-large] using system;
Using system. Collections. Generic;
Using system. text;
Using system. Data;
Using system. Windows. forms;
Using system. reflection;
Namespace DMS{/// /// C # Excel operations/// Class exceloperate{// Method 1 // Public bool datasettoexcel (Dataset dataset, bool isshowexcle)//{// Datatab
/**/
/**/
/**/
/// /// Import all data in dataset to excel /// You need to add COM: Microsoft Excel Object Library /// Using Excel; /// /// File Path /// Dataset to be stored
Public
/** // /// Import all data in dataset to excel
/// You need to add COM: Microsoft Excel Object Library
/// Using Excel;
/// /// /// Public static void exporttoexcel (string filepath, dataset DS)
...{
Object omissing = system. refl
], Excel. Cells[rowindex, Colindex]). Font.Bold = true;Fill in the values and proceed to the next columnExcel. Cells[rowindex, colindex++] = Col. ColumnName;}Get data from a dataset tableint drvindex;for (Drvindex = Dvrowstart; Drvindex //{New row, current cell moved to beginning of linerowindex++;Colindex = 1;for (int i = 1; I //{String AA = Dv[sheetindex]. Tabl
Basic data import is often involved in projects. In most cases, you need to obtain data from Excel. The following describes how to extract data from an Excel file to Dataset:
/// /// Extract the table
/// /// Method 3 for reading data from an Excel table, return the dataset Dataset
/// /// /// Private dataset getexceldataset1 (string strexcelfilepath)
{
Try
{
/// Establish a connection to read data in the table
String strcon =
Use oledb in. Net to export dataset data to an Excel file
Function Description:
// DT is the data source (data table)
// Excelfilename is the excle file to be exported.
// Modelfile is a template file, which is consistent with the table in the
excel| Data///Import all the data from the DataSet into Excel.
You need to add the Com:microsoft Excel Object Library.
Using Excel;
public static void exportToExcel (String filePath,
Use C # to convert data from Excel into a dataset without the help of a third-party plug-inThe above mentioned is the whole content of this article, I hope you can like.In addition to the Declaration,Running GuestArticles are original, reproduced please link to the form of the address of this articleC # converts data f
} the the theDataTable =NULL; - inWorkbook.close (true, Misvalue, Misvalue); the the Excel. Quit (); About the the Releaseobject (WorkSheet); the + Releaseobject (WorkBook); - the Releaseobject (Excel); Bayi the } the - Private Static voidReleaseobject (Objectobj) - { the Try the { the System.Runtim
Basic data import is often involved in projects. In most cases, you need to obtain data from Excel. The following describes how to extract data from an Excel file to Dataset:
/// /// Extract the table
The example in this article describes the C # implementation of the DataSet data into Excel and Word files in the general class. Share to everyone for your reference, specific as follows:
Not long ago because the project needs to write a C # to convert the dataset data into
1. First, right-click "Reference" in "project" in "solution" and introduce the Exel component in the COM component, as shown in: (versions may be different, which does not affect, I installed Office 2003) 2. Program To add the following statement:Imports Microsoft. Office. InterOP3. Create a new process function and output it to excel: Private sub Button2_click ( Byval Sender As System. object, Byval E As System. eventargs) Handles Button2.click Dim
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.