我有一个包含一个js文件createTable(// Create statistics table and // Creates APDEX table)
。
我需要得到// Create statistics table
值转换为字符串,这样我可以复制到Excel使用json2xsl。 有没有什么办法让那些"Create statistics table"
的数据值转换为字符串?
我在这里附上我的js文件
function summaryTableHeader(header) {
var newRow = header.insertRow(-1);
newRow.className = "tablesorter-no-sort";
var cell = document.createElement('th');
cell.setAttribute("data-sorter", false);
cell.colSpan = 1;
cell.innerHTML = "Requests";
newRow.appendChild(cell);
cell = document.createElement('th');
cell.setAttribute("data-sorter", false);
cell.colSpan = 3;
cell.innerHTML = "Executions";
newRow.appendChild(cell);
cell = document.createElement('th');
cell.setAttribute("data-sorter", false);
cell.colSpan = 7;
cell.innerHTML = "Response Times (ms)";
newRow.appendChild(cell);
cell = document.createElement('th');
cell.setAttribute("data-sorter", false);
cell.colSpan = 2;
cell.innerHTML = "Network (KB/sec)";
newRow.appendChild(cell);
}
function createTable(table, info, formatter, defaultSorts, seriesIndex, headerCreator) {
var tableRef = table[0];
// Create header and populate it with data.titles array
var header = tableRef.createTHead();
// Call callback is available
if (headerCreator) {
headerCreator(header);
}
var newRow = header.insertRow(-1);
for (var index = 0; index < info.titles.length; index++) {
var cell = document.createElement('th');
cell.innerHTML = info.titles[index];
newRow.appendChild(cell);
}
var tBody;
// Create overall body if defined
if (info.overall) {
tBody = document.createElement('tbody');
tBody.className = "tablesorter-no-sort";
tableRef.appendChild(tBody);
var newRow = tBody.insertRow(-1);
var data = info.overall.data;
for (var index = 0; index < data.length; index++) {
var cell = newRow.insertCell(-1);
cell.innerHTML = formatter ? formatter(index, data[index]) : data[index];
}
}
// Create regular body
tBody = document.createElement('tbody');
tableRef.appendChild(tBody);
var regexp;
if (seriesFilter) {
regexp = new RegExp(seriesFilter, 'i');
}
// Populate body with data.items array
for (var index = 0; index < info.items.length; index++) {
var item = info.items[index];
if ((!regexp || filtersOnlySampleSeries && !info.supportsControllersDiscrimination || regexp.test(item.data[seriesIndex])) &&
(!showControllersOnly || !info.supportsControllersDiscrimination || item.isController)) {
if (item.data.length > 0) {
var newRow = tBody.insertRow(-1);
for (var col = 0; col < item.data.length; col++) {
var cell = newRow.insertCell(-1);
cell.innerHTML = formatter ? formatter(col, item.data[col]) : item.data[col];
}
}
}
}
// Add support of columns sort
table.tablesorter({
sortList: defaultSorts
});
}
$(document).ready(function() {
// Customize table sorter default options
$.extend($.tablesorter.defaults, {
theme: 'blue',
cssInfoBlock: "tablesorter-no-sort",
widthFixed: true,
widgets: ['zebra']
});
// Creates APDEX table
createTable($("#apdexTable"), {
"supportsControllersDiscrimination": true,
"overall": {
"data": [0.6416666666666667, 500, 1500, "Total"],
"isController": false
},
"titles": ["Apdex", "T (Toleration threshold)", "F (Frustration threshold)", "Label"],
"items": [{
"data": [1.0, 500, 1500, "http://10.0.70.18:8443/assets/componentsConf/highcharts.json"],
"isController": false
}, {
"data": [0.3, 500, 1500, "Case Search 5 years - HDFC"],
"isController": false
}, {
"data": [1.0, 500, 1500, "Widget Filer - day : Last 7 Days, caseType : All, widgetName : CURRENT_ACTIVITY_ONLINE_ELEMENTS_SUMMARY"],
"isController": false
}, {
"data": [0.45, 500, 1500, "Widget Filer - day : Last Year, caseType : Advance Fee Fraud, widgetName : SHUTDOWN_MEDIAN"],
"isController": false
}, {
"data": [0.5, 500, 1500, "Widget Filer - day : Last 90 Days, caseType : Advance Fee Fraud, widgetName : ATTACK_STATUS_OVERVIEW"],
"isController": false
}, {
"data": [1.0, 500, 1500, "Widget Filer - day : Last 30 Days, caseType : Vishing, widgetName : ATTACK_TRENDING_CASES_N_ELEMENTS"],
"isController": false
}, {
"data": [0.0, 500, 1500, "Element Search and Export 1 year - All"],
"isController": true
}, {
"data": [0.0, 500, 1500, "Findings Search 1 year - All"],
"isController": false
}, {
"data": [0.15, 500, 1500, "Findings Export 2 years - HDFC"],
"isController": false
}, {
"data": [0.5, 500, 1500, "Widget Filer - day : YTD, caseType : All, widgetName : ATTACK_STATUS_OVERVIEW"],
"isController": false
}, {
"data": [0.3, 500, 1500, "Element Export 2 years - HDFC"],
"isController": false
}, {
"data": [0.4, 500, 1500, "Widget Filer - day : YTD, caseType : Vishing, widgetName : SHUTDOWN_MEDIAN"],
"isController": false
}, {
"data": [0.0, 500, 1500, "Widget Filer - day : Customized 5 Years, caseType : Advance Fee Fraud, widgetName : ATTACK_TRENDING_CASES_N_ELEMENTS"],
"isController": false
}, {
"data": [0.5, 500, 1500, "Widget Filer - day : MTD, caseType : All, widgetName : ATTACK_STATUS_OVERVIEW"],
"isController": false
}, {
"data": [0.5, 500, 1500, "Widget Filer - day : Customized 3 Years, caseType : Brand Abuse, widgetName : ATTACK_STATUS_OVERVIEW"],
"isController": false
}, {
"data": [1.0, 500, 1500, "Widget Filer - day : Last 90 Days, caseType : Vishing, widgetName : ATTACK_TRENDING_CASES_N_ELEMENTS"],
"isController": false
}, {
"data": [0.5, 500, 1500, "Widget Filer - day : Last Year, caseType : Trojan, widgetName : ATTACK_STATUS_OVERVIEW"],
"isController": false
}, {
"data": [0.5, 500, 1500, "Widget Filer - day : Customized 2 Years, caseType : Brand Abuse, widgetName : ATTACK_STATUS_OVERVIEW"],
"isController": false
}, {
"data": [1.0, 500, 1500, "Element Search 3 years - HDFC"],
"isController": false
}, {
"data": [0.5, 500, 1500, "Widget Filer - day : Last 7 Days, caseType : All, widgetName : ATTACK_STATUS_OVERVIEW"],
"isController": false
}, {
"data": [0.55, 500, 1500, "Widget Filer - day : Last 30 Days, caseType : Phishing, widgetName : SHUTDOWN_MEDIAN"],
"isController": false
}, {
"data": [0.7, 500, 1500, "Widget Filer - day : Customized 5 Years, caseType : Advance Fee Fraud, widgetName : SHUTDOWN_MEDIAN"],
"isController": false
}, {
"data": [0.4, 500, 1500, "Widget Filer - day : Customized 3 Years, caseType : Advance Fee Fraud, widgetName : SHUTDOWN_MEDIAN"],
"isController": false
}, {
"data": [1.0, 500, 1500, "Widget Filer - day : Last Day, caseType : Brand Abuse, widgetName : ATTACK_STATUS_OVERVIEW"],
"isController": false
}, {
"data": [0.45, 500, 1500, "Widget Filer - day : Customized 2 Years, caseType : Advance Fee Fraud, widgetName : SHUTDOWN_MEDIAN"],
"isController": false
}, {
"data": [0.8, 500, 1500, "Widget Filer - day : Last 30 Days, caseType : Advance Fee Fraud, widgetName : ATTACK_STATUS_OVERVIEW"],
"isController": false
}, {
"data": [1.0, 500, 1500, "Widget Filer - day : WTD, caseType : Trojan, widgetName : SHUTDOWN_MEDIAN"],
"isController": false
}, {
"data": [0.15, 500, 1500, "Case Search and Export 2 years - HDFC"],
"isController": true
}]
}, function(index, item) {
switch (index) {
case 0:
item = item.toFixed(3);
break;
case 1:
case 2:
item = formatDuration(item);
break;
}
return item;
}, [
[0, 0]
], 3);
// Create statistics table
createTable($("#statisticsTable"), {
"supportsControllersDiscrimination": true,
"overall": {
"data": ["Total", 3640, 10, 0.27472527472527475, 3639.9299450549524, 13, 538740, 10765.800000000001, 12825.8, 20110.160000000033, 1.7694735670302353, 372.0607477266944, 2.1349031653767496],
"isController": false
},
"titles": ["Label", "#Samples", "KO", "Error %", "Average", "Min", "Max", "90th pct", "95th pct", "99th pct", "Throughput", "Received", "Sent"],
"items": [{
"data": ["http://10.0.70.18:8443/assets/componentsConf/highcharts.json", 10, 0, 0.0, 20.4, 13, 27, 27.0, 27.0, 27.0, 126.58227848101266, 152.6651503164557, 46.35581487341772],
"isController": false
}, {
"data": ["Case Search 5 years - HDFC", 10, 0, 0.0, 1255.0, 442, 1665, 1664.3, 1665.0, 1665.0, 1.0187449062754685, 1.0595344972493888, 1.3510308425020374],
"isController": false
}, {
"data": ["Widget Filer - day : Last 7 Days, caseType : All, widgetName : CURRENT_ACTIVITY_ONLINE_ELEMENTS_SUMMARY", 60, 0, 0.0, 38.55, 27, 112, 44.9, 47.949999999999996, 112.0, 5.434782608695652, 3.4816576086956523, 6.644870923913044],
"isController": false
}, {
"data": ["Widget Filer - day : Last Year, caseType : Advance Fee Fraud, widgetName : SHUTDOWN_MEDIAN", 10, 0, 0.0, 1047.6, 471, 1681, 1676.5, 1681.0, 1681.0, 2.1654395842356, 1.057343546990039, 2.6243266836292767],
"isController": false
}, {
"data": ["Widget Filer - day : Last 90 Days, caseType : Advance Fee Fraud, widgetName : ATTACK_STATUS_OVERVIEW", 10, 0, 0.0, 1232.8000000000002, 791, 1472, 1471.5, 1472.0, 1472.0, 6.7658998646820026, 3.4754524695534506, 8.24594046008119],
"isController": false
}, {
"data": ["Widget Filer - day : Last 30 Days, caseType : Vishing, widgetName : ATTACK_TRENDING_CASES_N_ELEMENTS", 10, 0, 0.0, 47.300000000000004, 40, 67, 65.2, 67.0, 67.0, 80.0, 41.40625, 97.5],
"isController": false
}, {
"data": ["Element Search and Export 1 year - All", 10, 0, 0.0, 18169.4, 16511, 22844, 22679.3, 22844.0, 22844.0, 0.4369865408145429, 8869.709134247727, 1.142395478281769],
"isController": true
}, {
"data": ["Findings Search 1 year - All", 10, 0, 0.0, 39922.5, 39823, 40099, 40098.4, 40099.0, 40099.0, 0.24925845609312294, 0.46784643809666243, 0.31838873102520004],
"isController": false
}, {
"data": ["Findings Export 2 years - HDFC", 10, 0, 0.0, 3505.2999999999997, 660, 4744, 4744.0, 4744.0, 4744.0, 0.46268449544255774, 258.4888146023227, 0.5846813838893259],
"isController": false
}, {
"data": ["Widget Filer - day : YTD, caseType : All, widgetName : ATTACK_STATUS_OVERVIEW", 10, 0, 0.0, 1024.3, 926, 1161, 1158.1, 1161.0, 1161.0, 6.43915003219575, 3.3516278976175147, 7.759678847392145],
"isController": false
}, {
"data": ["Element Export 2 years - HDFC", 10, 0, 0.0, 1637.4, 296, 2263, 2262.9, 2263.0, 2263.0, 0.36537688625817527, 194.47648628466513, 0.4838389235996931],
"isController": false
}, {
"data": ["Widget Filer - day : YTD, caseType : Vishing, widgetName : SHUTDOWN_MEDIAN", 10, 0, 0.0, 1229.6000000000001, 524, 1585, 1582.4, 1585.0, 1585.0, 3.1938677738741617, 1.559505748961993, 3.839503153944427],
"isController": false
}, {
"data": ["Widget Filer - day : Customized 5 Years, caseType : Advance Fee Fraud, widgetName : ATTACK_TRENDING_CASES_N_ELEMENTS", 10, 0, 0.0, 4181.0, 3998, 4375, 4369.5, 4375.0, 4375.0, 2.2416498542927594, 1.8738791750728534, 2.7539018717776282],
"isController": false
}, {
"data": ["Widget Filer - day : MTD, caseType : All, widgetName : ATTACK_STATUS_OVERVIEW", 10, 0, 0.0, 802.5999999999999, 729, 887, 883.8, 887.0, 887.0, 8.77963125548727, 4.544145083406497, 10.580141571553995],
"isController": false
}, {
"data": ["Widget Filer - day : Customized 3 Years, caseType : Brand Abuse, widgetName : ATTACK_STATUS_OVERVIEW", 10, 0, 0.0, 845.5, 756, 950, 948.4, 950.0, 950.0, 9.19963201471941, 4.779496320147194, 11.158147424103037],
"isController": false
}, {
"data": ["Widget Filer - day : Last 90 Days, caseType : Vishing, widgetName : ATTACK_TRENDING_CASES_N_ELEMENTS", 10, 0, 0.0, 76.2, 70, 84, 83.5, 84.0, 84.0, 54.6448087431694, 29.136782786885245, 66.59836065573771],
"isController": false
}, {
"data": ["Widget Filer - day : Last Year, caseType : Trojan, widgetName : ATTACK_STATUS_OVERVIEW", 10, 0, 0.0, 603.5999999999999, 517, 687, 685.0, 687.0, 687.0, 11.037527593818986, 5.72356167218543, 13.33341956401766],
"isController": false
}, {
"data": ["Widget Filer - day : Customized 2 Years, caseType : Brand Abuse, widgetName : ATTACK_STATUS_OVERVIEW", 10, 0, 0.0, 774.7, 684, 894, 892.3, 894.0, 894.0, 11.1731843575419, 5.793907122905027, 13.551850558659218],
"isController": false
}, {
"data": ["Element Search 3 years - HDFC", 10, 0, 0.0, 110.6, 90, 149, 147.3, 149.0, 149.0, 0.6148548942449582, 1.9988788505287753, 0.8256108199090015],
"isController": false
}, {
"data": ["Widget Filer - day : Last 7 Days, caseType : All, widgetName : ATTACK_STATUS_OVERVIEW", 10, 0, 0.0, 665.6999999999998, 559, 788, 786.8, 788.0, 788.0, 4.2426813746287655, 2.1959190708527787, 5.112762515910055],
"isController": false
}, {
"data": ["Widget Filer - day : Last 30 Days, caseType : Phishing, widgetName : SHUTDOWN_MEDIAN", 10, 0, 0.0, 1061.5, 387, 1336, 1335.7, 1336.0, 1336.0, 4.249893752656183, 2.3200103591160217, 5.11315342116447],
"isController": false
}, {
"data": ["Widget Filer - day : Customized 5 Years, caseType : Advance Fee Fraud, widgetName : SHUTDOWN_MEDIAN", 10, 0, 0.0, 732.3000000000001, 433, 1052, 1051.0, 1052.0, 1052.0, 2.5329280648429586, 1.2788318452380953, 3.0696911410840935],
"isController": false
}, {
"data": ["Widget Filer - day : Customized 3 Years, caseType : Advance Fee Fraud, widgetName : SHUTDOWN_MEDIAN", 10, 0, 0.0, 1220.1, 670, 1967, 1964.5, 1967.0, 1967.0, 1.9054878048780488, 0.9304139672256098, 2.3092874666539633],
"isController": false
}, {
"data": ["Widget Filer - day : Last Day, caseType : Brand Abuse, widgetName : ATTACK_STATUS_OVERVIEW", 10, 0, 0.0, 340.9, 334, 351, 350.4, 351.0, 351.0, 4.452359750667854, 2.287051981300089, 5.400225400712378],
"isController": false
}, {
"data": ["Widget Filer - day : Customized 2 Years, caseType : Advance Fee Fraud, widgetName : SHUTDOWN_MEDIAN", 10, 0, 0.0, 1037.9, 413, 1528, 1527.3, 1528.0, 1528.0, 2.1593608291945583, 1.0543754048801555, 2.616959754912546],
"isController": false
}, {
"data": ["Widget Filer - day : Last 30 Days, caseType : Advance Fee Fraud, widgetName : ATTACK_STATUS_OVERVIEW", 10, 0, 0.0, 568.1, 291, 965, 965.0, 965.0, 965.0, 5.040322580645161, 2.5841497605846775, 6.14289314516129],
"isController": false
}, {
"data": ["Widget Filer - day : WTD, caseType : Trojan, widgetName : SHUTDOWN_MEDIAN", 10, 0, 0.0, 25.7, 23, 29, 28.9, 29.0, 29.0, 4.154549231408392, 2.2355045180722892, 4.990327690070627],
"isController": false
}, {
"data": ["Case Search and Export 2 years - HDFC", 10, 0, 0.0, 2819.0, 505, 5606, 5480.3, 5606.0, 5606.0, 0.2926115581565472, 52.82810213972202, 0.7706771214337967],
"isController": true
}, {
"data": ["Widget Filer - day : MTD, caseType : Advance Fee Fraud, widgetName : ATTACK_TRENDING_CASES_N_ELEMENTS", 10, 0, 0.0, 37.699999999999996, 30, 43, 42.8, 43.0, 43.0, 37.03703703703704, 18.952546296296294, 45.5005787037037],
"isController": false
}]
}, function(index, item) {
switch (index) {
// Errors pct
case 3:
item = item.toFixed(2) + '%';
break;
// Mean
case 4:
// Mean
case 7:
// Percentile 1
case 8:
// Percentile 2
case 9:
// Percentile 3
case 10:
// Throughput
case 11:
// Kbytes/s
case 12:
// Sent Kbytes/s
item = item.toFixed(2);
break;
}
return item;
}, [
[0, 0]
], 0, summaryTableHeader);
});