update
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using ClosedXML;
|
||||
using FastReport;
|
||||
using FastReport.Export.OoXML;
|
||||
using FastReport.Export.Pdf;
|
||||
@@ -67,7 +68,105 @@ namespace rmutr_report.Controllers
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
||||
[HttpPost, Route("reports/compensation_head_department/{type}")]
|
||||
[ApiExplorerSettings(GroupName = "reports")]
|
||||
public IActionResult GetComReport([FromRoute] string type, [FromBody] compensation_head three)
|
||||
{
|
||||
if (three.data!=null)
|
||||
{
|
||||
var s = three.data.Sum(f => f.budget_amount);
|
||||
|
||||
three.total_amount = s;
|
||||
}
|
||||
|
||||
var threes = new List<compensation_head>() { three };
|
||||
|
||||
Report report = new Report();
|
||||
report.Load(_setting.report_path + "compensation_head_department.frx");
|
||||
report.RegisterData(threes, "compensation_head");
|
||||
report.Prepare();
|
||||
|
||||
MemoryStream stream = new MemoryStream();
|
||||
switch (type)
|
||||
{
|
||||
case "pdf":
|
||||
PDFExport pdf = new PDFExport();
|
||||
report.Export(pdf, stream);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
return File(stream, "application/pdf");
|
||||
case "xls":
|
||||
case "xlsx":
|
||||
Excel2007Export excel = new Excel2007Export();
|
||||
report.Export(excel, stream);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
//return File(stream, "application/vnd.ms-excel");
|
||||
string date = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||
return File(
|
||||
stream,
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
date + ".xlsx");
|
||||
break;
|
||||
case "doc":
|
||||
case "docx":
|
||||
Word2007Export word = new Word2007Export();
|
||||
report.Export(word, stream);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
return File(stream, "appllication/vnd.ms-word");
|
||||
break;
|
||||
}
|
||||
|
||||
return Ok();
|
||||
}
|
||||
[HttpPost, Route("reports/compensation_head_major/{type}")]
|
||||
[ApiExplorerSettings(GroupName = "reports")]
|
||||
public IActionResult GetCom2Report([FromRoute] string type, [FromBody] compensation_head three)
|
||||
{
|
||||
if (three.data!=null)
|
||||
{
|
||||
var s = three.data.Sum(f => f.budget_amount);
|
||||
|
||||
three.total_amount = s;
|
||||
}
|
||||
|
||||
var threes = new List<compensation_head>() { three };
|
||||
|
||||
Report report = new Report();
|
||||
report.Load(_setting.report_path + "compensation_head_major.frx");
|
||||
report.RegisterData(threes, "compensation_head");
|
||||
report.Prepare();
|
||||
|
||||
MemoryStream stream = new MemoryStream();
|
||||
switch (type)
|
||||
{
|
||||
case "pdf":
|
||||
PDFExport pdf = new PDFExport();
|
||||
report.Export(pdf, stream);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
return File(stream, "application/pdf");
|
||||
case "xls":
|
||||
case "xlsx":
|
||||
Excel2007Export excel = new Excel2007Export();
|
||||
report.Export(excel, stream);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
//return File(stream, "application/vnd.ms-excel");
|
||||
string date = DateTime.Now.ToString("yyyyMMddHHmmss");
|
||||
return File(
|
||||
stream,
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
date + ".xlsx");
|
||||
break;
|
||||
case "doc":
|
||||
case "docx":
|
||||
Word2007Export word = new Word2007Export();
|
||||
report.Export(word, stream);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
return File(stream, "appllication/vnd.ms-word");
|
||||
break;
|
||||
}
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user