Commit cd3fa7af authored by dutdut's avatar dutdut

.

parent 19bbb662
......@@ -43,6 +43,7 @@ namespace testImport
public string value { get; set; }
public DateTime Time { get; set; }
public DateTime created { get; set; }
public string tmp { get; set; }
}
public class Program
......@@ -71,7 +72,7 @@ namespace testImport
var filePath = @"C:\Users\Admin\Downloads\HR_SK.xlsx";
byte[] file = File.ReadAllBytes(filePath);
//List<saved> XX = new List<saved>();
List<saved> XX = new List<saved>();
using (MemoryStream stream = new MemoryStream(file))
{
using (ExcelPackage excelPackage = new ExcelPackage(stream))
......@@ -80,15 +81,25 @@ namespace testImport
while (firstSheet == _MAXSHEET)
{
var DataSheet = excelPackage.Workbook.Worksheets[firstSheet];
for (int i = 0; i <= DataSheet.Dimension.End.Row - Convert.ToInt32(BODY); i+=SEED) //i+=seed
for (int i = 108; i <= DataSheet.Dimension.End.Row - Convert.ToInt32(BODY); i+=SEED) //i+=seed
{
//check last: if STT is not number => stop
var testLast = DataSheet.Cells["A" + (Convert.ToInt32(BODY) + i).ToString()].Value is null ? " " : DataSheet.Cells["A" + (Convert.ToInt32(BODY) + i).ToString()].Value.ToString();
if (!int.TryParse(testLast, out _)) //https://stackoverflow.com/questions/894263/identify-if-a-string-is-a-number
break;
foreach (var value in customer_Templates.Where(c => c.sheet == firstSheet).ToList())
{
var Address = value.coordinate as String + (Convert.ToInt32(BODY) + i).ToString();
if (!value.coordinate.Contains(":"))
{
string xxxxx = DataSheet.Cells[Address].Value.ToString();
string xxxxx = DataSheet.Cells[Address].Value is null ? "" : DataSheet.Cells[Address].Value.ToString();
saved save = new saved();
save.value = xxxxx;
save.id_excel_template = value.id_excel_template;
XX.Add(save);
}
else
{
......@@ -98,24 +109,33 @@ namespace testImport
for(int ii = 0; ii < countsub; ii++)
{
Address = split[0] + (Convert.ToInt32(BODY) + i + ii).ToString() + ":" + split[1] + (Convert.ToInt32(BODY) + i + ii).ToString();
var range = DataSheet.Cells[Address];
foreach (var rangeBasse in range)
{
saved save = new saved();
string xxx = rangeBasse.Value is null ? "" : rangeBasse.Value.ToString();
save.value = xxx;
save.id_excel_template = value.id_excel_template;
var tmpx = new[] { "vào", "ra", "tăng ca", "tông công" };
save.tmp = tmpx[ii];
XX.Add(save);
}
}
}
}
}
firstSheet++;
}
}
}
Console.WriteLine("xxx");
}
}
......
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