Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8500951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T01:04:51+00:00 2026-06-11T01:04:51+00:00

I would like to add the hyperlink in export the dataTable into excel But

  • 0

I would like to add the hyperlink in export the dataTable into excel

But the excel cannot show the hyperlink property, only strings.

Is there any limitation for the dataTable input field ?

below is my code for formatting the DATATABLE

       int dt_current_row = 0;
        string[] Days = testDays.ToArray();

        for (int i = 0; i < tableOriginal.Rows.Count; i++)
        {
            string wo_number = handle(tableOriginal.Rows[i]["WO_NUMBER"].ToString());
            string date = handle(tableOriginal.Rows[i]["CREATE_DATE"].ToString());

            if (i == 0)
            {

                // Insert New
                DataRow dr = dt.NewRow();
                dt.Rows.Add(dr);
                dr["WO_NUMBER"] = wo_number;

                for (int x = 1; x < dt.Columns.Count; x++)
                {
                    int z = Convert.ToInt32(Math.Floor(0.5 * (x - 1)));
                    //search Date
                    if (tableOriginal.Rows[i]["CREATE_DATE"].ToString() == Days[z])
                    {
                        //if equal , insert num and ID 
                        object xx = tableOriginal.Rows[i]["NUM"];
                        int num = Convert.ToInt32(xx);
                        dr["PHOTO_" + z.ToString()] = num;

                        object yy = tableOriginal.Rows[i]["PHOTO_ID"];
                        string photo = Convert.ToString(yy);
                        dr["ID_" + z.ToString()] = HttpContext.Current.Server.HtmlEncode(httpLink + photo);

                        break;
                    }
                }
            }

….and the part to export cells in DataTable into cells in excel Document xls
I have tried to set the formula but it doesn’t work

foreach (DataRow r in result.Rows)
    {
        currentCol = 1;
        foreach (DataColumn c in result.Columns)
        {
            string temp = c.ColumnName.ToString().Substring(0,2);
            if (temp.Equals("ID")) 
            {
                httpLinkForPhoto = r[currentCol - 1].ToString();
                if (!httpLinkForPhoto.Equals(null))
                {
                    string formula = "=HYPERLINK(" + httpLinkForPhoto + "," + httpLinkForPhoto + ")";
                    excelDoc2.SetFormula(1, 1, currentRow, currentCol, currentRow, currentCol, formula);
                }
            }
            else
            { 
                excelDoc2.setCell(1, 1, currentRow, currentCol, r[currentCol - 1].ToString()); 
            }            
            currentCol++;
        }
        currentRow++;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T01:04:52+00:00Added an answer on June 11, 2026 at 1:04 am

    A .net DataTable may only contain .net Types. So there is no possibility to add a “hyperlink” within a dataTable. But of course you may add a hyperlink to an excel Cell. See this question or MSDN for details on adding a hyperlink to excel. According to your code this may look like

    // common syntax to  add a Hyperlink to Excel
    object Add(
    [In] object Anchor, 
    [In] string Address, 
    [In, Optional] object SubAddress, 
    [In, Optional] object ScreenTip, 
    [In, Optional] object TextToDisplay
    );
    
    // your code
    for (int rowIndex=0; rowIndex<result.Rows.Count; rowIndex++)
    {
        for (int columnIndex=0; columnIndex<result.Columns.Count; columnIndex++)
        {
            string yourValue = result.Rows[rowIndex].Item[columnIndex].ToString();
            if (columnIndex!=YOUR_HYPERLINK_COLUMN_INDEX)
                excelDoc2.setCell(1, 1, rowIndex, columnIndex, yourValue);      
            else
            {
                 Excel.Range range = (Range) YOUR_SHEET.Cells[rowIndex, columnIndex];
    
                 CURRENT_WORKSHEET.Hyperlinks.Add(
                               range, 
                               yourValue, 
                               Type.Missing,"YOUR_SCREEN_TIP",
                               "YOUR_TEXT_TO_DISPLAY");
            } 
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to do something like add a nice-to-Excel-functions Name property to the
I would like to add a hash into an array using Ruby version 1.8.7:
I have own project and i would like add for this class same as
I have a ListView and each item have a TextView. I would like add
I would like to add a GestureDetector to all views (view groups) of an
I would like to add a custom calculation method to a managed object (which
I would like to add roots to a VirtualTreeView http://www.delphi-gems.com/index.php/controls/virtual-treeview with a thread like
I would like to add up the number of line changes in an SVN
I would like to add a pop effect when I hover over a SVG
I would like to add a small dice-rolling effect to my Javascript code. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.