Đang chuẩn bị liên kết để tải về tài liệu:
Import Export Excel với C# 2005

Không đóng trình duyệt đến khi xuất hiện nút TẢI XUỐNG

Chức năng Import Khi thực hiện chức năng lấy dữ liệu từ excel thì những bước quan trọng nhất là : - Chuỗi kết nối với Excel ( cho phép kết nối với cả excel 2007) Conn="Provider=Microsoft.ACE.OLEDB.12.0; DataSource=D:\\Data\\Excel.xslx; Extended Properties = 12.0"; | Import Export Excel với C 2005 Chức năng Import Khi thực hiện chức năng lấy dữ liệu từ excel thì những bước quan trọng nhất là - Chuỗi kết nối với Excel cho phép kết nối với cả excel 2007 strConn Provider Microsoft.ACE.OLEDB. 12.0 DataSource D Data Excel.xslx Extended Properties 12.0 - Thực hiện việc truy vấn dữ liệu và đổ vào dataset hoặc đưa thẳng vào database bằng cách thay đổi câu lệnh query OleDbDataAdapter da new OleDbDataAdapter Select ten_column1 ten_column2 . from Sheet strConn - Từ dataset đưa dữ liệu vào dabase Chức năng Export Để export được dữ liệu ra excel thì trước tiên ta phải khai báo các thư viện sử dụng liên quan đến Excel using Microsoft.Office.Interop.Excel using VBIDE_12 Microsoft.Vbe.Interop using Office_12 Microsoft.Office.Core using Excel_12 Microsoft.Office.Interop.Excel Tiếp đó export dữ liệu từ database ra excel ApplicationClass excel new ApplicationClass excel.Application.Workbooks.Add true Excel_12.Application oExcel_12 null Excel_12 Application Excel_12.Workbook oBook null Excel_12 Workbook Excel_12.Sheets oSheetsColl null Excel_12 Worksheets collection Excel_12.Worksheet oSheet null Excel_12 Worksheet Excel_12.Range oRange null Cell or Range in worksheet Object oMissing System.Reflection.Missing.Value oExcel_12 new Excel_12.Application Make Excel_12 visible to the user. oExcel_12.Visible true Set the UserControl property so Excel_12 won t shut down. oExcel_12.UserControl true System.Globalization.CultureInfo ci new System.Globalization.CultureInfo en-US Add a workbook. oBook oExcel_12.Workbooks.Add oMissing Get worksheets collection oSheetsColl oExcel_12.Worksheets oSheet Excel_12.Worksheet oSheetsColl.get_Item Sheet1 for int j 0 j dsExcel.Tables 0 .Columns.Count j oRange Excel_12.Range oSheet.Cells 1 j 1 oRange.Value2 dsExcel.Table 0 .Columns j .ColumnName for int i 0 i dsExcel.Tables 0 .Rows.Count i for int j 0 j dsExcel.Tables 0 .Columns.Count j oRange Excel_12.Range oSheet.Cells i 2 j 1

TÀI LIỆU LIÊN QUAN
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.