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.