How to pass hyperlinks in excel
kiranakhale opened this issue · 1 comments
Hi,
I would like to have hyperlink field in my excel.
Can someone help me with it?
Following is my code used
var file = {
worksheets: [],
creator: 'Analyze',
author: 'Analyze',
created: new Date(),
lastModifiedBy: 'Analyze',
modified: new Date(),
activeWorksheet: 0
};
var resultType = Search.resultType();
var projectExcelHeaderRow = ['Project Name', 'Matching Searches', 'Bid Date', 'Project Value', 'Country Code'];
var companyExcelHeaderRow = ['Company Name', 'Country', 'State', 'County', 'Role Classification Parent', 'Role Classification'];
$.merge(companyExcelHeaderRow,Search.matchingQueryTitles());
//Pick the apropriate header row
var excelHeaderRow = resultType == 'Projects' ? projectExcelHeaderRow : companyExcelHeaderRow;
var excludeColumns = resultType == 'Projects' ? ['id', 'url', 'sqFt','leadsEntitled'] : ['id','sortValue','dataSource','url', 'sqFt','bidDate','leadsEntitled'] ;
var worksheetIndex = file.worksheets.push([]) - 1;
var worksheet = file.worksheets[worksheetIndex];
// Maximum of 31 characters.
worksheet.name = resultType + ' Result List';
worksheet.data = [];
//Pass the header row first.
worksheet.data[0] = excelHeaderRow;
var entityListing = Search.FindExportEntityListing(resultType);
$.each(entityListing.entities, function (index, entity) {
var row = worksheet.data.push([]) - 1;
$.each(entity, function(pindex, entityValue) {
if (excludeColumns.indexOf(pindex) == -1 ) {
if (pindex == 'matchingQueries' && resultType == 'Companies') {
$.each(entityValue,function(index,entity){
worksheet.data[row].push(entity);
});
}
else
{
if (pindex == 'matchingQueries' && resultType == 'Projects') {
entityValue = Search.MapSearchQueryLabels(entityValue);
}
if (pindex == 'bidDate') {
var bidDate = (iso8601NoTime(entity.bidDate));
entityValue = (bidDate != '0001-01-01')? bidDate : ' ';
}
if (pindex == 'name') {
}
worksheet.data[row].push(entityValue);
}
}
});
});
var fileName = exportFileName + "_" + sampleDt +".xls";
var a = document.createElement('a');
a.id = "downloadExcel";
a.setAttribute('download', fileName);
a.href = xlsx(file).href();
a.style.display = 'none';
document.body.appendChild(a);
a.click();
$('#downloadExcel').remove();
I would like to how to know how to pass hyperlinks to excel or
how to pass formula to excel so that i will pass "=HYPERLINK('https://www.google.com','tweeswrtsfd')"
or how to pass html data to excel which be rendered as normal text for eg - test this would be rendered in excel as test with hyperlink to google.com
Can some provide an example with xlxs.js? We are currently using this js and we would require hyperlinks in export to excel