我有必须在excel中的各个工作表中显示的json数组值,因此我使用了以下json格式
var opts=[
{
"sheetid": "Ali",
"header": false
},
{
"sheetid": "Ari",
"header": false
}]
var exportArray=[
[
{
"driver": "Ari",
"round_trip_number": "7",
"trip_name": "L-R-L",
"vehicle": "WB7520Q",
"distance_profile": "KM_Scheme1_30_90",
"scheme_name": "CA_Scheme_A",
"actual_weight": 0,
"actual_litre": 0,
"weight_price": 0,
"distance_price": 0,
"trip_price": 0,
"estimated_distance": 48.44
},
{
"driver": "Ari",
"round_trip_number": "6",
"trip_name": "R-P",
"vehicle": "WB7520Q",
"distance_profile": "KM_Scheme1_30_90",
"scheme_name": "CA_Scheme_A",
"actual_weight": 8000,
"actual_litre": 7000,
"weight_price": 36,
"distance_price": 60,
"trip_price": 0,
"estimated_distance": 656.62
}
],
[
{
"driver": "Ali",
"round_trip_number": "4",
"trip_name": "L-P-L",
"vehicle": "BGV1852",
"scheme_name": "TA_Scheme_A",
"actual_weight": 30000,
"actual_litre": 21000,
"weight_price": 0,
"distance_price": 0,
"trip_price": 0,
"drum_qty": 140,
"drum_price": 0,
"estimated_distance": 313.5
}
]]
我需要将excel中的列值求和并显示在相应列的末尾。我使用alasql脚本来执行此功能。 excel是在我使用以下查询时生成的。
var result = alasql('SELECT * INTO XLSX("DriverComponesation.xlsx",?) FROM ?', [opts, exportArray]);
但是当我使用以下查询总结列值时,不会生成excel。
var result = alasql('select * INTO XLSX("DriverComponesation.xlsx",?) from (SELECT * FROM ? x union all select null, null ,null ,null ,null ,null ,sum(actual_weight) actual_weight,null,null,null,null,null,null,null,null,null,null,null,null,null,null from ? ) o ', [opts, exportArray]);
任何人都可以使用上面的json数组帮助我获得excel中的总和。