In the last post, I have shown the method to write hyperlink in Excel worksheet. But if I want to read hyperlinks in this Excel file to a textbox without opening it, how to do?
Now, this post focuses on how to read hyperlink from Excel by using C#.
At first, create a new Windows Form Application Project and name it ReadHyperlink. Secondly, create a form and name it, then design. In the form. I add one label at the top of form as a title. Add another two labels to point out which the text boxes will show. Add two text boxes following by cue words. Finally, add a button for reading.
Then, we can find a well designed form as following.
OK, double click Read and write code for realizing my requirement.
Also, I use Spire.XLS in this method, therefore, add dll file as reference firstly. Next, use the following code.
public partial class Form1 : Form
private void button1_Click(object sender, EventArgs e)
//Get Excel File with Hyperlink
Workbook workbook = new Workbook();
Worksheet sheet = workbook.Worksheets;
//Read Hyperlink to TextBox
textBox1.Text = sheet.HyperLinks.Address;
textBox2.Text = sheet.HyperLinks.Address;
Click Here to learn more about Spire.XLS.
Click Here to download Spire.XLS.