Commit fc7baa8f by IMRAN AHMED KHAN

codeFormatted

parent ffa172b3
...@@ -28,11 +28,12 @@ namespace ExcelToJson.Controllers ...@@ -28,11 +28,12 @@ namespace ExcelToJson.Controllers
{ {
return new string[] { "value1", "value2" }; return new string[] { "value1", "value2" };
} }
// GET api/values // GET api/values
[HttpGet("excel/getJson")] [HttpGet("excel/getJson")]
public ActionResult GetJson() public ActionResult GetJson()
{ {
Utility utility =new Utility(); Utility utility = new Utility();
var webRoot = _env.WebRootPath; var webRoot = _env.WebRootPath;
FileInfo file = new FileInfo(System.IO.Path.Combine(webRoot, "savar-shivalay-manual data-v3.xlsx")); FileInfo file = new FileInfo(System.IO.Path.Combine(webRoot, "savar-shivalay-manual data-v3.xlsx"));
List<ProjectData> projectDataList = new List<ProjectData>(); List<ProjectData> projectDataList = new List<ProjectData>();
...@@ -42,7 +43,7 @@ namespace ExcelToJson.Controllers ...@@ -42,7 +43,7 @@ namespace ExcelToJson.Controllers
{ {
for (int i=1;i<= package.Workbook.Worksheets.Count;i++) for (int i = 1; i <= package.Workbook.Worksheets.Count; i++)
{ {
ExcelWorksheet worksheet = package.Workbook.Worksheets[i]; ExcelWorksheet worksheet = package.Workbook.Worksheets[i];
int rowCount = worksheet.Dimension.Rows; int rowCount = worksheet.Dimension.Rows;
...@@ -53,93 +54,96 @@ namespace ExcelToJson.Controllers ...@@ -53,93 +54,96 @@ namespace ExcelToJson.Controllers
int counter = 1; int counter = 1;
if( worksheet.Cells[row, 1].Value!=null ){ if (worksheet.Cells[row, 1].Value != null)
projectData.PROJECTID=worksheet.Cells[row, 1].Value.ToString(); {
projectData.PROJECTID = worksheet.Cells[row, 1].Value.ToString();
} }
if( worksheet.Cells[row, 2].Value!=null ){ if (worksheet.Cells[row, 2].Value != null)
projectData.CODE_PART1=worksheet.Cells[row, 2].Value.ToString();; {
projectData.CODE_PART1 = worksheet.Cells[row, 2].Value.ToString(); ;
} }
if( worksheet.Cells[row, 3].Value!=null ){ if (worksheet.Cells[row, 3].Value != null)
projectData.CODE_PART2=worksheet.Cells[row, 3].Value.ToString();; {
projectData.CODE_PART2 = worksheet.Cells[row, 3].Value.ToString(); ;
} }
if( worksheet.Cells[row, 4].Value!=null ){ if (worksheet.Cells[row, 4].Value != null)
projectData.PROJECTTITLE=worksheet.Cells[row, 4].Value.ToString();; {
projectData.PROJECTTITLE = worksheet.Cells[row, 4].Value.ToString(); ;
} }
if( worksheet.Cells[row, 5].Value!=null ){ if (worksheet.Cells[row, 5].Value != null)
{
projectData.PROJECTNAME = worksheet.Cells[row, 5].Value.ToString(); projectData.PROJECTNAME = worksheet.Cells[row, 5].Value.ToString();
} }
if( worksheet.Cells[row, 6].Value!=null ){ if (worksheet.Cells[row, 6].Value != null)
projectData.SCHEMENAME_ENG=worksheet.Cells[row, 6].Value.ToString();; {
projectData.SCHEMENAME_ENG = worksheet.Cells[row, 6].Value.ToString(); ;
} }
if( worksheet.Cells[row, 7].Value!=null ){ if (worksheet.Cells[row, 7].Value != null)
projectData.SCHEMENAME_BEN=worksheet.Cells[row, 7].Value.ToString();; {
projectData.SCHEMENAME_BEN = worksheet.Cells[row, 7].Value.ToString(); ;
} }
if( worksheet.Cells[row, 8].Value!=null ){ if (worksheet.Cells[row, 8].Value != null)
projectData.PACKAGEID=worksheet.Cells[row, 8].Value.ToString();; {
projectData.PACKAGEID = worksheet.Cells[row, 8].Value.ToString(); ;
} }
if( worksheet.Cells[row, 9].Value!=null ){ if (worksheet.Cells[row, 9].Value != null)
{
projectData.PACKAGECODE = worksheet.Cells[row, 9].Value.ToString(); projectData.PACKAGECODE = worksheet.Cells[row, 9].Value.ToString();
} }
if( worksheet.Cells[row, 10].Value!=null ){ if (worksheet.Cells[row, 10].Value != null)
projectData.COMPONENTSUBHEADID=worksheet.Cells[row, 10].Value.ToString();; {
projectData.COMPONENTSUBHEADID = worksheet.Cells[row, 10].Value.ToString(); ;
} }
if( worksheet.Cells[row, 11].Value!=null ){ if (worksheet.Cells[row, 11].Value != null)
projectData.COMPONENTSUBHEADNAME=worksheet.Cells[row, 11].Value.ToString();; {
projectData.COMPONENTSUBHEADNAME = worksheet.Cells[row, 11].Value.ToString(); ;
} }
if( worksheet.Cells[row, 12].Value!=null ){ if (worksheet.Cells[row, 12].Value != null)
{
projectData.UPAZILAID = worksheet.Cells[row, 12].Value.ToString(); projectData.UPAZILAID = worksheet.Cells[row, 12].Value.ToString();
} }
if (worksheet.Cells[row, 13].Value != null) if (worksheet.Cells[row, 13].Value != null)
{ {
projectData.ROADID = worksheet.Cells[row, 13].Value.ToString(); projectData.ROADID = worksheet.Cells[row, 13].Value.ToString();
} }
if ( worksheet.Cells[row, 14].Value!=null ){ if (worksheet.Cells[row, 14].Value != null)
{
projectData.ROADLENGTH = worksheet.Cells[row, 14].Value.ToString(); projectData.ROADLENGTH = worksheet.Cells[row, 14].Value.ToString();
} }
if( worksheet.Cells[row, 15].Value!=null ){ if (worksheet.Cells[row, 15].Value != null)
projectData.DISTRICTID=worksheet.Cells[row, 15].Value.ToString();; {
projectData.DISTRICTID = worksheet.Cells[row, 15].Value.ToString(); ;
} }
if( worksheet.Cells[row, 16].Value!=null ){ if (worksheet.Cells[row, 16].Value != null)
projectData.ACOMPLETIONDATE = Utility.GetStandardFormattedDate(worksheet.Cells[row, 16].Value.ToString()) ; {
projectData.ACOMPLETIONDATE = Utility.GetStandardFormattedDate(worksheet.Cells[row, 16].Value.ToString());
} }
if( worksheet.Cells[row, 17].Value!=null ){ if (worksheet.Cells[row, 17].Value != null)
{
projectData.CONTRACTORNAME = worksheet.Cells[row, 17].Value.ToString(); projectData.CONTRACTORNAME = worksheet.Cells[row, 17].Value.ToString();
} }
if (worksheet.Cells[row, 18].Value != null)
{
projectData.CONTRACTSIGNDATE = Utility.GetStandardFormattedDate(worksheet.Cells[row, 18].Value.ToString());
if( worksheet.Cells[row, 18].Value!=null ){
projectData.CONTRACTSIGNDATE =Utility.GetStandardFormattedDate(worksheet.Cells[row, 18].Value.ToString()) ;
} }
if( worksheet.Cells[row, 19].Value!=null ){ if (worksheet.Cells[row, 19].Value != null)
projectData.FINANCIALYEAR=worksheet.Cells[row, 19].Value.ToString();; {
projectData.FINANCIALYEAR = worksheet.Cells[row, 19].Value.ToString(); ;
} }
if( worksheet.Cells[row, 20].Value!=null ){ if (worksheet.Cells[row, 20].Value != null)
projectData.SCHEMECODE=worksheet.Cells[row, 20].Value.ToString();; {
projectData.SCHEMECODE = worksheet.Cells[row, 20].Value.ToString(); ;
} }
if( worksheet.Cells[row, 21].Value!=null ){ if (worksheet.Cells[row, 21].Value != null)
projectData.PHYSICALPROGGRESS = worksheet.Cells[row,21].Value.ToString(); {
projectData.PHYSICALPROGGRESS = worksheet.Cells[row, 21].Value.ToString();
} }
if( worksheet.Cells[row, 22].Value!=null ){ if (worksheet.Cells[row, 22].Value != null)
projectData.STATUS=worksheet.Cells[row, 22].Value.ToString();; {
projectData.STATUS = worksheet.Cells[row, 22].Value.ToString(); ;
} }
projectDataList.Add(projectData); projectDataList.Add(projectData);
} }
} }
...@@ -149,7 +153,7 @@ namespace ExcelToJson.Controllers ...@@ -149,7 +153,7 @@ namespace ExcelToJson.Controllers
} }
catch (Exception ex) catch (Exception ex)
{ {
//return "Some error occured while importing." + ex.Message; return Ok("Some error occured while importing." + ex.Message);
} }
return Ok(projectDataList); return Ok(projectDataList);
...@@ -159,9 +163,9 @@ namespace ExcelToJson.Controllers ...@@ -159,9 +163,9 @@ namespace ExcelToJson.Controllers
//export a excel file //export a excel file
/* /*
[HttpGet] [HttpGet]
[Route("Export")] [Route("Export")]
public string Export() public string Export()
{ {
string sWebRootFolder = _hostingEnvironment.WebRootPath; string sWebRootFolder = _hostingEnvironment.WebRootPath;
string sFileName = @"demo.xlsx"; string sFileName = @"demo.xlsx";
string URL = string.Format("{0}://{1}/{2}", Request.Scheme, Request.Host, sFileName); string URL = string.Format("{0}://{1}/{2}", Request.Scheme, Request.Host, sFileName);
...@@ -200,15 +204,14 @@ public string Export() ...@@ -200,15 +204,14 @@ public string Export()
package.Save(); //Save the workbook. package.Save(); //Save the workbook.
} }
return URL; return URL;
} }*/
*/
//read from a excel //read from a excel
/* /*
[HttpGet] [HttpGet]
[Route("Import")] [Route("Import")]
public string Import() public string Import()
{ {
string sWebRootFolder = _hostingEnvironment.WebRootPath; string sWebRootFolder = _hostingEnvironment.WebRootPath;
string sFileName = @"demo.xlsx"; string sFileName = @"demo.xlsx";
FileInfo file = new FileInfo(Path.Combine(sWebRootFolder, sFileName)); FileInfo file = new FileInfo(Path.Combine(sWebRootFolder, sFileName));
...@@ -243,7 +246,9 @@ public string Import() ...@@ -243,7 +246,9 @@ public string Import()
{ {
return "Some error occured while importing." + ex.Message; return "Some error occured while importing." + ex.Message;
} }
}*/ }
*/
// GET api/values/5 // GET api/values/5
[HttpGet("{id}")] [HttpGet("{id}")]
......
91c3067690a97cdc4d11db1ac361192d56571460 400339070a838111c02fcd0e2f0e5e42cb5e9487
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