This commit is contained in:
@@ -9,6 +9,7 @@ using FastReport.Export.Mht;
|
||||
using FastReport.Export.OoXML;
|
||||
using FastReport.Export.Pdf;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using OfficeOpenXml;
|
||||
using rmutr_report.Models;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
|
||||
@@ -29,25 +30,25 @@ namespace rmutr_report.Controllers
|
||||
public IActionResult GetHrReport([FromRoute] string type,
|
||||
[FromBody] durable_articles_three durable_articles_threes)
|
||||
{
|
||||
//Console.WriteLine(durable_articles_threes.specification_data[0].data_detail[0].data_detail2);
|
||||
// var a1 = durable_articles_threes.data.Sum(o => o.amount);
|
||||
// if (durable_articles_threes.data!=null)
|
||||
// {
|
||||
// durable_articles_threes.total_amount = a1;
|
||||
//
|
||||
// }
|
||||
|
||||
// int a = 1;
|
||||
// foreach (var q in durable_articles_threes.quotation)
|
||||
// {
|
||||
//
|
||||
// string t = "ใบเสนอราคาบริษัทที่ " + a++ +" ";
|
||||
// q.company = t + q.company;
|
||||
// //a++;
|
||||
// }
|
||||
//Console.WriteLine(durable_articles_threes.specification_data[0].data_detail[0].data_detail2);
|
||||
// var a1 = durable_articles_threes.data.Sum(o => o.amount);
|
||||
// if (durable_articles_threes.data!=null)
|
||||
// {
|
||||
// durable_articles_threes.total_amount = a1;
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
var _durable_articles_three = new List<durable_articles_three>() {durable_articles_threes};
|
||||
// int a = 1;
|
||||
// foreach (var q in durable_articles_threes.quotation)
|
||||
// {
|
||||
//
|
||||
// string t = "ใบเสนอราคาบริษัทที่ " + a++ +" ";
|
||||
// q.company = t + q.company;
|
||||
// //a++;
|
||||
// }
|
||||
|
||||
|
||||
var _durable_articles_three = new List<durable_articles_three>() { durable_articles_threes };
|
||||
|
||||
Report report = new Report();
|
||||
report.Load(_setting.report_path + "durable_articles_three.frx");
|
||||
@@ -65,14 +66,6 @@ namespace rmutr_report.Controllers
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
return File(stream, "application/pdf");
|
||||
|
||||
case "xls":
|
||||
case "xlsx":
|
||||
Excel2007Export excel = new Excel2007Export();
|
||||
excel.ShowProgress = true;
|
||||
excel.PageBreaks = true;
|
||||
report.Export(excel, stream);
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
break;
|
||||
case "mht":
|
||||
MHTExport mht = new MHTExport();
|
||||
@@ -86,15 +79,55 @@ namespace rmutr_report.Controllers
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
return File(stream, "text/csv");
|
||||
break;
|
||||
case "doc" : case "docx":
|
||||
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;
|
||||
}
|
||||
case "xls":
|
||||
case "xlsx":
|
||||
Excel2007Export excelExport = new Excel2007Export
|
||||
{
|
||||
ShowProgress = true,
|
||||
PageBreaks = true
|
||||
};
|
||||
report.Export(excelExport, stream);
|
||||
|
||||
return Ok();
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
using (var package = new ExcelPackage(stream))
|
||||
{
|
||||
ExcelWorksheet worksheet = package.Workbook.Worksheets[0];
|
||||
|
||||
if (worksheet.Dimension != null)
|
||||
{
|
||||
//worksheet.Cells[worksheet.Dimension.Address].AutoFitColumns();
|
||||
worksheet.Cells[worksheet.Dimension.Address].Style.WrapText = true;
|
||||
}
|
||||
|
||||
package.Save();
|
||||
}
|
||||
|
||||
stream.Seek(0, SeekOrigin.Begin);
|
||||
return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||
|
||||
}
|
||||
// static double GetTextHeight(string text, double fontSize, bool wrapText)
|
||||
// {
|
||||
// if (string.IsNullOrEmpty(text))
|
||||
// return 0;
|
||||
//
|
||||
//
|
||||
// const double lineHeightFactor = 1.2;
|
||||
//
|
||||
// int lines = wrapText ? text.Split(new[] { '\n' }, StringSplitOptions.None).Length : 1;
|
||||
// return lines * (fontSize * lineHeightFactor);
|
||||
// }
|
||||
|
||||
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user