Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the method of C # operating excel

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "what is the method of C # operating excel". In the daily operation, I believe that many people have doubts about the method of operating excel in C#. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts of "what is the method of operating excel in C#?" Next, please follow the editor to study!

When we do excel materials, we usually have the following methods.

one。 Import and export excel common methods: 1. Query and show on the dataset control by querying the table. Public static string strCon = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source = C:\\ 08.xlsscape extended Properties=Excel 8.0"; public static DataSet ds; protected void Page_Load (object sender, EventArgs e) {OleDbConnection conn = new OleDbConnection (strCon); string sql = "select * from [Sheet1 $]"; conn.Open (); OleDbDataAdapter myCommand = new OleDbDataAdapter (sql, strCon); ds = new DataSet () MyCommand.Fill (ds, "[Sheet1 $]"); conn.Close (); datagrid1.DataMember = "[Sheet1 $]"; datagrid1.DataSource = ds; datagrid1.DataBind (); / / Excel.Application excel = new Excel.Application (); / / excel.Application.Workbooks.Add (true); / / excel.Visible = true;} 2. Insert cell by cell string str = @ "Data Source=IT-428E4EA4B0C7\ SQLEXPRESS;Initial Catalog=TestBase;Integrated Security=True"; SqlConnection conn = new SqlConnection (str); conn.Open (); int n = 0; for (int I = 1; I

< 20; i++) { if (n >

3) break; else if (msheet.Cells.get_Range ("A" + I, Type.Missing). Text.ToString () = "" & & n

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report