Paste the content of 10 consecutive cells in the copy Excel file into 10 textbox items at a time.

Source: Internet
Author: User

Recently, many people proposed to directly paste the information in the Excel file. It was too troublesome to lose hands, so I tried it.

At the beginning, I went to the tip of the horn and thought about getting the content in the clipboard.

Later, we found that we can directly paste the copied content into textbox1, and then use the content change event of textbox1 to process it, split the string, and assign it to the textbox control one by one.

I encountered a problem here, that is, I don't know what is the separator between the contact cells in Excel. I tested it and used 0x09 to separate it. In fact, 0x09 is a tab, that is, \ t.

With these problems, we can solve them well. Let's look at the code below:

protected void TextBox1_TextChanged(object sender, EventArgs e)    {        try        {            string strs = TextBox1.Text.ToString();            string[] ss = strs.Split('\t');            for (int i = 0; i < ss.Length; i++)            {            }            TextBox1.Text = ss[0];            TextBox2.Text = ss[1];            TextBox3.Text = ss[2];            TextBox4.Text = ss[3];            TextBox5.Text = ss[4];            TextBox6.Text = ss[5];            TextBox7.Text = ss[6];            TextBox8.Text = ss[7];            TextBox9.Text = ss[8];            TextBox10.Text = ss[9];            TextBox11.Text = ss[10];            TextBox12.Text = ss[11];            TextBox13.Text = ss[12];            TextBox14.Text = ss[13];            TextBox15.Text = ss[14];            TextBox16.Text = ss[15];            TextBox17.Text = ss[16];        }        catch { }    }

In fact, the problem is very simple: Assign the copied value to STRs first, and then use
\ T to be separated, and then assigned to the corresponding Textbox Control, it is OK to pull.

Paste the content of 10 consecutive cells in the copy Excel file into 10 textbox items at a time.

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.