Commit 79b937ed by guanzhenshan

资产负债表增加导出功能

parent 48f4b4b0
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
......@@ -261,8 +262,50 @@ namespace Bailun.DC.Web.Areas.Reports.Controllers
m.count_liabilities_and_oe = m.count_liabilities + m.oe_count;
}
var colNames = new List<string>() { "数值" };
colNames.AddRange(list.Select(p => p.statistical_time.ToString("yyyy-MM-dd")));
var listresult = new List<string>();
return View();
for (var i = 0; i < list.Count; i++)
{
var m0 = list[i];
var listProperties = m0.GetType().GetProperties();
var rowindex = 0;
for(var o=0;o<listProperties.Length;o++)
{
var descriptionName = "";
var v = (DescriptionAttribute[])listProperties[o].GetCustomAttributes(typeof(DescriptionAttribute), false);
if (v.Length > 0)
{
descriptionName = v[0].Description;
}
if (descriptionName == "")
{
continue;
}
var value = listProperties[o].GetValue(m0, null).ToString();
if (i == 0) //添加字段名称
{
listresult.Add(descriptionName);
}
var temp = listresult[rowindex] + "|" + value;
listresult[rowindex] = temp;
rowindex++;
}
}
var filename = "资产负债表 " + DateTime.Now.ToString("yyyyMMddHHmmss");
var filepath = _hostingEnvironment.WebRootPath + "\\Files\\Report\\" + DateTime.Now.ToString("yyyy-MM-dd") + "\\";
ToCSV(listresult, colNames, filename, filepath);
return File("~/Files/Report/" + DateTime.Now.ToString("yyyy-MM-dd") + "/" + filename + ".csv", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", filename + ".csv");
}
/// <summary>
......
......@@ -27,6 +27,7 @@
<option value="2" selected>香港百伦科技有限公司</option>*@
</select>
<button type="button" class="btn btn-sm btn-primary" onclick="GetData();"><i class="fa fa-search"></i>&nbsp;查询</button>
<button type="button" class="btn btn-sm btn-success" onclick="ExportXsl()">导出</button>
</div>
</div>
</form>
......@@ -998,6 +999,14 @@
})
return res;
}
function ExportXsl() {
var type = $('#timetype').val();
var day = $('#day').val();
var paycompany = $('#sel_paycompany').val();
window.open('@Url.Content("~/Reports/Finance/ExportIndex?")' + 'type=' + type + '&day=' + day + '&paycompanyvalue=' + paycompany, '_blank');
}
</script>
}
......
......@@ -27,6 +27,7 @@
<option value="2" selected>香港百伦科技有限公司</option>*@
</select>
<button type="button" class="btn btn-sm btn-primary" onclick="GetData();"><i class="fa fa-search"></i>&nbsp;查询</button>
<button type="button" class="btn btn-sm btn-success" onclick="ExportXsl();">导出</button>
</div>
</div>
</form>
......@@ -1446,6 +1447,14 @@
}
function ExportXsl() {
var type = $('#timetype').val();
var day = $('#day').val();
var paycompany = $('#sel_paycompany').val();
window.open('@Url.Content("~/Reports/Finance/ExportIndex?")' + 'type=' + type + '&day=' + day + '&paycompanyvalue=' + paycompany, '_blank');
}
</script>
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment