-
Notifications
You must be signed in to change notification settings - Fork 121
Description
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();