I am not able add hyper link in excel work book for a sheet to another sheet of same work book


#1

hi

in worksheet.hyperlinks i am not finding AddInternalLink method i can see only add method

my requirement is to add hyperlink to another spread sheet in same work book


#2

AddInternalLink method is merged into Add method. Please try:

Workbook excel = new Workbook();
excel.Worksheets.Add();
excel.Worksheets[0].Hyperlinks.Add(0, 0, 1, 1, "sheet2!A10");

excel.Save("d:\\test\\abc.xls");


#3

this is the code i wrote

excel.Worksheets[0].Hyperlinks.Add(8, 3, 1, 1, excel.Worksheets[1].Name+"!A1");

i am getting error refarence is not valid when i click on the cell


#4

What happens if you run my sample code?

Does this error occur in your program or in your file? Could you please post your code and file here? And which version of Aspose.Cells are you using?


#5

DataSet objDs = (DataSet)Cache["Result"];

DataTable dtResult;

dtResult = objDs.Tables[5];

if (ExportType == ExportFormat.Excel)

{

Workbook excel = new Workbook();

excel.Open(@"Templets/ExtractTableExcel.xls");

Aspose.Cells.Cells exportCells = excel.Worksheets[0].Cells;

exportCells.ImportDataTable(dtResult, true, 7, 0, true);

for (int i = 0; i < dtResult.Columns.Count; i++)

{

excel.Worksheets[0].Cells[7, i].Style.Number = 49;

excel.Worksheets[0].Cells[7, i].Style.Pattern = BackgroundType.ThinHorizontalStripe;

excel.Worksheets[0].Cells[7, i].Style.BackgroundColor = System.Drawing.Color.Aqua;

excel.Worksheets[0].Cells[7, i].Style.Font.IsBold = true;

}

Bitmap bmp = chResult.GetChartBitmap();

int rowNumber = dtResult.Rows.Count + 11;

MemoryStream ms = new MemoryStream();

bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);

excel.Worksheets[0].Pictures.Add(rowNumber, 1, ms);

ms.Flush();

excel.Worksheets[0].Hyperlinks.Add(8, 7, 1, 1, excel.Worksheets[1].Name+"!A10");

excel.Save("Datamonitor Excel", Aspose.Cells.FileFormatType.ExcelXP, Aspose.Cells.SaveType.OpenInExcel, Response);

when i click one button this code will get executeed and it promts message box to save ,open,cancle options

i select open and try to use the link i created it says refarnce is not valid

i added the excel file please check it


#6

ok now i am getting

thanq