如何添加超链接 [英] How to add Hyperlink

查看:159
本文介绍了如何添加超链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此代码创建的excel文件每张中有10张,并将"TEST DATA"放入单元格中.
当我单击测试数据"时,如何在测试数据"单元格上添加超级链接,然后工作表将更改.


this code create excel file with 10 sheets in every sheet have "TEST DATA" into cell.
how to add hyper link on "TEST DATA" cell when i click on "TEST DATA" then sheet will change.


int i = 1;
            if (source != null || source.Tables.Count == 0)
            {
                foreach (DataTable dt in source.Tables)
                {
                    sw.Write("<Worksheet ss:Name=\"" + replaceXmlChar(dt.TableName) + "\"><Table><Row><Cell  ss:StyleID=\"s62\"><Data ss:Type=\"String\"></Data></Cell></Row> ");
                    //sw.Write("<Worksheet ss:Name=\"" + replaceXmlChar(dt.TableName) + "\"><Table><Row><Cell  ss:StyleID=\"s62\"><Data ss:Type=\"String\"></Data> </Cell></Row></Table></Worksheet>");
                    sw.Write("<Row>\r\n");
                    dt.Columns.Add("Data");
                    dt.Rows.Add("Test Data" + i);
                    i++;
                    foreach (DataColumn dc in dt.Columns)
                    {
                        sw.Write(
                              string.Format("<Cell ss:StyleID=\"s62\"><Data ss:Type=\"String\">{0}</Data></Cell>",
                                          replaceXmlChar(dt.Rows[0][dc.ColumnName].ToString())));

                    } sw.Write("</Row>\r\n");
                    sw.Write("</Table></Worksheet>");
                }

请帮助我.

推荐答案

嗨.

您可以使用Office附带的Excel库.

使用此链接上手(尽管代码在VB中).

http://support.microsoft.com/kb/219151 [ http://stackoverflow.com/questions/1333772/adding-hyperlinks-in-excel2007-in-c-sharp-within-excel-it-self [
Hi.

You can use the Excel libraries included in Office.

Use to this link to get started (code is in VB though).

http://support.microsoft.com/kb/219151[^]

You will see here that the Excel object is used and various other objects (e.g. Worksheet).

Then you can write your data into the appropriate sheet / cell.

With regards to having a hyperlink within an excel spreadsheet, the link below should assist:

http://stackoverflow.com/questions/1333772/adding-hyperlinks-in-excel2007-in-c-sharp-within-excel-it-self[^]


这篇关于如何添加超链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆