add export excel

This commit is contained in:
kamonwan taengsuk
2023-03-29 21:57:16 +07:00
parent 0e59f3c39c
commit f38f9ce5f9
13 changed files with 1069 additions and 287 deletions

View File

@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using ClosedXML.Excel;
using FastReport;
using FastReport.Export.Csv;
using FastReport.Export.Mht;
@@ -11,11 +10,10 @@ using FastReport.Export.OoXML;
using FastReport.Export.Pdf;
using Microsoft.AspNetCore.Mvc;
using rmutr_report.Models;
using Swashbuckle.AspNetCore.Annotations;
namespace rmutr_report.Controllers
{
[SwaggerTag("สำหรับรายงาน ง.4")]
//[SwaggerTag("สำหรับรายงาน ง.4")]
public class BuildingFour : Controller
{
readonly Setting _setting;
@@ -141,43 +139,23 @@ namespace rmutr_report.Controllers
}
else if (str.Length == 7)
{
for (int i = 1; i <= str.Length - 1; i += 7)
for (int i = 1,j=5; i <= str.Length -1 ;i +=7,j+=7)
{
boqPrice.list = str.Insert(i, ",");
boqPrice.list = str.Insert(i, ",").Insert(j,",");
}
for (int i = 4; i <= str.Length - 1; i += 7)
}
else if (str.Length == 8)
{ for (int i = 2,j=6; i <= str.Length -1 ;i +=8,j+=8)
{
boqPrice.list = str.Insert(i, ",");
boqPrice.list = str.Insert(i, ",").Insert(j,",");
}
}
else if (str.Length == 7)
{
for (int i = 4; i <= str.Length - 1; i += 7)
{
boqPrice.list = str.Insert(i, ",");
}
}
// else if (str.Length == 8)
// {
// // boqPrice.list.Replace("10000000", "10,000,000");
// // boqPrice.list.Replace("10000000.0000", "10,000,000");
// for (int i = 2; i <= str.Length - 1; i += 8)
// {
// boqPrice.list = str.Insert(i, ",");
// //boqPrice.list = str.Insert(i, ",");
// }
//
// for (int i = 5; i <= str.Length - 1; i += 8)
// {
// boqPrice.list = str.Insert(i, ",");
// //boqPrice.list = str.Insert(i, ",");
// }
// }
if (boqPrice.list == "10000000")
{
boqPrice.list = "10,000,000";
}
// if (boqPrice.list == "10000000")
// {
// boqPrice.list = "10,000,000";
// }
}
foreach (var boqPrice in building_fours.boq)
@@ -208,47 +186,22 @@ namespace rmutr_report.Controllers
}
else if (str.Length == 7)
{
for (int i = 1; i <= str.Length - 1; i += 7)
for (int i = 1,j=5; i <= str.Length -1 ;i +=7,j+=7)
{
boqPrice.have = str.Insert(i, ",");
}
for (int i = 4; i <= str.Length - 1; i += 7)
{
boqPrice.have = str.Insert(i, ",");
}
}
else if (str.Length == 7)
{
for (int i = 1; i <= str.Length - 1; i += 7)
{
boqPrice.have = str.Insert(i, ",");
boqPrice.have = str.Insert(i, ",").Insert(j,",");
}
}
// else if (str.Length == 8)
// {
// // boqPrice.have.Replace("10000000", "10,000,000");
// // boqPrice.have.Replace("10000000.0000", "10,000,000");
// for (int i = 2; i <= str.Length - 1; i += 8)
// {
// boqPrice.have = str.Insert(i, ",");
// //boqPrice.have = str.Insert(i, ",");
// }
//
// for (int i = 5; i <= str.Length - 1; i += 8)
// {
// boqPrice.have = str.Insert(i, ",");
// //boqPrice.list = str.Insert(i, ",");
// }
// //
// // boqPrice.have.Replace("10000000", "10,000,000");
// // boqPrice.have.Replace("10000000.0000", "10,000,000");
// //
// }
if (boqPrice.have == "10000000")
{
boqPrice.have = "10,000,000";
else if (str.Length == 8)
{ for (int i = 2,j=6; i <= str.Length -1 ;i +=8,j+=8)
{
boqPrice.have = str.Insert(i, ",").Insert(j,",");
}
}
// if (boqPrice.have == "10000000")
// {
// boqPrice.have = "10,000,000";
// }
boqPrice.text1 = "- มี วงเงิน " + boqPrice.have + " บาท";
boqPrice.text2 = "- ดำเนินการจัดทำ BOQ เดือน " + boqPrice.pending_boq_month;
boqPrice.text3 = "- BOQ แล้วเสร็จเดือน " + boqPrice.done_boq_month;
@@ -265,6 +218,19 @@ namespace rmutr_report.Controllers
}
}
foreach (var expense in building_fours.expense_category)
{
if (expense!=null)
{
var a = building_fours.expense_category.Where(d => d.amount == d.amount)
.Sum(o => o.amount);
building_fours.total_expense = a;
building_fours.total_expense_vat = (a * 7)/100;
building_fours.total_allexpense_vat = building_fours.total_expense+building_fours.total_expense_vat;
}
}
var _building_fours = new List<building_four>() { building_fours };