C # Implementation to quickly read TXT text data into Excel

Source: Internet
Author: User
Tags readline reflection split

This article mainly introduces the C # implementation of the TXT text data quickly read to Excel, this article directly to show example code, need friends can refer to the next

Today, the implementation of a function, the TXT data to the Excel table, as a data source for MATLAB. Collect some C # operation Excel programs. The steps are as follows:

Download a Microsoft.Office.Interop.Excel.dll reference in the project.

Write the code as follows:

?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 The

The above code can realize the function, because the data in TXT has 60501 rows, the amount of data is too large. I calculated that it would take about 2-3 minutes to go to excel with the above code. I want to transfer 9 txt altogether. It will take more than 20 minutes altogether. Such a system is obviously intolerable. Then find the data, found that using the rang method can improve the rate. It takes only about 3-4 seconds to increase the efficiency by dozens of times times. The code is as follows:

?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 The

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.