Fix issue with pasting results in Teams (#13673)

* Fix issue with pasting results in Teams

* Addressed comment to change header tag to th

Co-authored-by: Monica Gupta <mogupt@microsoft.com>
This commit is contained in:
Monica Gupta
2020-12-04 15:41:53 -08:00
committed by GitHub
parent 6349f1bd49
commit 4092b6493b

View File

@@ -157,15 +157,16 @@ export class CopyQueryWithResultsKeyboardAction extends Action {
let resultSummary = queryRunner.batchSets[0].resultSetSummaries[i];
let result = await queryRunner.getQueryRows(0, resultSummary.rowCount, resultSummary.batchId, resultSummary.id);
let tableHeaders = resultSummary.columnInfo.map((col, i) => (col.columnName));
let htmlTableHeaders = resultSummary.columnInfo.map((col, i) => (`<th style="border:solid black 1.0pt; whiteSpace:nowrap">${escape(col.columnName)}</th>`));
let htmlTableHeaders = `<thead><tr style="background-color:DarkGray">${resultSummary.columnInfo.map((col, i) => (`<th style="border:1.0px solid black;padding:3pt;font-size:9pt;font-weight: bold;">${escape(col.columnName)}</th>`)).join('')}</tr></thead>`;
let copyString = '\n';
let htmlCopyString = '<tr>';
let htmlCopyString = '';
for (let rowEntry of result.rows) {
htmlCopyString = htmlCopyString + '<tr>';
for (let colIdx = 0; colIdx < rowEntry.length; colIdx++) {
let value = rowEntry[colIdx].displayValue;
copyString = `${copyString}${value}\t`;
htmlCopyString = `${htmlCopyString}<td style="border:solid black 1.0pt;white-space:nowrap">${escape(value)}</td>`;
htmlCopyString = `${htmlCopyString}<td style="border:1.0px solid black;padding:3pt;font-size:9pt;">${escape(value)}</td>`;
}
// Removes the tab seperator from the end of a row
copyString = copyString.slice(0, -1 * '\t'.length) + '\n';
@@ -175,7 +176,7 @@ export class CopyQueryWithResultsKeyboardAction extends Action {
allResults = `${allResults}${tableHeaders.join('\t')}${copyString}\n`;
allHtmlResults = `${allHtmlResults}<div><br/><br/>
<table cellPadding="5" cellSpacing="1" style="border:1;border-color:Black;font-family:Segoe UI;font-size:12px;border-collapse:collapse">
<tr style="background-color:DarkGray">${htmlTableHeaders.join('')}</tr>${htmlCopyString}
${htmlTableHeaders}${htmlCopyString}
</table></div>`;
}
}