Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
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.


C#
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>");
                }
please help me on it.
Posted
Updated 15-Feb-12 1:20am
v2

1 solution

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[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900