Articles in this section
Category / Section

How to Get Hyperlink URL From the CSV File Using WinForms XlsIO?

2 mins read

This article explains how to get a hyperlink URL from a CSV file using XlsIO.

To get the hyperlink URL from the CSV file that contains a formula, the calculated value property of the cell should be assigned to the value property of the cell.

To know more about accessing a calculated value, please refer to the documentation.

Code snippet to get hyperlink URL from CSV file:

worksheet.EnableSheetCalculations();
foreach (IRange range in worksheet.UsedRange)
{
     // Assign the calculated value to the value of the cell
     range.Value = range.CalculatedValue;
}
worksheet.DisableSheetCalculations();
// Export to DataTable
DataTable dt = worksheet.ExportDataTable(worksheet.UsedRange,ExcelExportDataTableOptions.None);

 

Download Complete Sample

Download input file with data

The following C#/VB complete code explains how to get a hyperlink URL from a CSV file using XlsIO.

C#

using Syncfusion.XlsIO;
using System.Data;
using System.IO;
using System.Reflection;
 
namespace HyperLink_URL
{
    class Program
    {
        static void Main(string[] args)
        {
            using (ExcelEngine excelEngine = new ExcelEngine())
            {
                // Instantiate the Excel application object.
                IApplication application = excelEngine.Excel;
 
                // The workbook is opened.
                IWorkbook workbook;
 
                // Open existing workbook with data entered
                Assembly assembly = typeof(Program).GetTypeInfo().Assembly;
                Stream fileStream = assembly.GetManifestResourceStream("Hyperlink_URL.Sample.csv");
 
                workbook = application.Workbooks.Open(fileStream, ExcelOpenType.Automatic);
 
                // The first worksheet object in the worksheets collection is accessed.
                IWorksheet worksheet = workbook.Worksheets[0];
 
                worksheet.EnableSheetCalculations();
                foreach (IRange range in worksheet.UsedRange)
                {
                    // Assign the calculated value to the value of the cell
                    range.Value = range.CalculatedValue;
                }
                worksheet.DisableSheetCalculations();
 
                // Export to DataTable
                DataTable dt = worksheet.ExportDataTable(worksheet.UsedRange, ExcelExportDataTableOptions.None);
 
                // Saving the workbook
                Stream stream = File.Create("Output.xlsx");
                workbook.SaveAs(stream);
            }
        }
    }
} 

VB

Imports Syncfusion.XlsIO
Imports System.Data
Imports System.IO
Imports System.Reflection
 
Namespace HyperLink_URL
 
    Class Program
 
        Private Shared Sub Main(ByVal args() As String)
            Dim excelEngine As ExcelEngine = New ExcelEngine
 
            'Instantiate the Excel application object.
            Dim application As IApplication = excelEngine.Excel
 
            'The workbook is opened.
            Dim workbook As IWorkbook
 
            'Open existing workbook with data entered
            Dim assembly As Assembly = GetType(Program).GetTypeInfo.Assembly
            Dim fileStream As Stream = assembly.GetManifestResourceStream("Hyperlink_URL.Sample.csv")
            workbook = application.Workbooks.Open(fileStream, ExcelOpenType.Automatic)
 
            'The first worksheet object in the worksheets collection is accessed.
            Dim worksheet As IWorksheet = workbook.Worksheets(0)
 
            worksheet.EnableSheetCalculations()
            For Each range As IRange In worksheet.UsedRange
                'Assign the calculated value to the value of the cell
                range.Value = range.CalculatedValue
            Next
            worksheet.DisableSheetCalculations()
 
            'Export to DataTable
            Dim dt As DataTable = worksheet.ExportDataTable(worksheet.UsedRange, ExcelExportDataTableOptions.None)
 
            'Saving the workbook
            Dim stream As Stream = File.Create("Output.xlsx")
            workbook.SaveAs(stream)
        End Sub
    End Class
End Namespace 

Take a moment to peruse the documentation where you can find basic Excel document processing options along with the features like import and export data, chart, formulas, conditional formatting, data validation, tables, pivot tables and protect the Excel documents, and most importantly, the PDF, CSV and Image conversions with code examples.

 

Conclusion

I hope you enjoyed learning about how to Get Hyperlink URL From the CSV File Using WinForms XlsIO.

You can refer to our XIsIO’s feature tour page to learn about its other groundbreaking features. Explore our UG documentation and online demos to understand how to manipulate data in Excel documents.

If you are an existing user, you can access our latest components from the License and Downloads page. For new users, you can try our 30-day free trial to check out XlsIO and other Syncfusion® components.

If you have any queries or require clarification, please let us know in the comments below or contact us through our support forumsSupport Tickets, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied