Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
UFTest
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
datdiep
UFTest
Commits
5dc498e7
Commit
5dc498e7
authored
Sep 20, 2022
by
datdiep
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Program.cs
parent
cd3fa7af
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
143 additions
and
143 deletions
+143
-143
Program.cs
testImport/Program.cs
+143
-143
No files found.
testImport/Program.cs
View file @
5dc498e7
using
OfficeOpenXml
;
using
System
;
using
System.Collections
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
namespace
testImport
{
public
class
excel_template
{
public
Guid
id
{
get
;
set
;
}
public
string
name
{
get
;
set
;
}
public
string
code
{
get
;
set
;
}
public
string
type
{
get
;
set
;
}
}
public
class
customer_template
{
public
Guid
id
{
get
;
set
;
}
public
Guid
customer_id
{
get
;
set
;
}
public
Guid
id_excel_template
{
get
;
set
;
}
public
int
sheet
{
get
;
set
;
}
public
string
coordinate
{
get
;
set
;
}
public
int
order
{
get
;
set
;
}
public
Guid
id_sub
{
get
;
set
;
}
public
int
body
{
get
;
set
;
}
public
int
merge
{
get
;
set
;
}
}
public
class
subdetail
{
public
Guid
id
{
get
;
set
;
}
public
Guid
id_excel_template
{
get
;
set
;
}
public
int
row
{
get
;
set
;
}
}
public
class
saved
{
public
Guid
id
{
get
;
set
;
}
public
Guid
id_excel_template
{
get
;
set
;
}
public
Guid
user_id
{
get
;
set
;
}
public
string
value
{
get
;
set
;
}
public
DateTime
Time
{
get
;
set
;
}
public
DateTime
created
{
get
;
set
;
}
public
string
tmp
{
get
;
set
;
}
}
public
class
Program
{
public
static
void
Main
(
string
[]
args
)
{
List
<
excel_template
>
excel_Templates
;
List
<
customer_template
>
customer_Templates
;
List
<
subdetail
>
Subdetails
;
Data
x
=
new
Data
();
excel_Templates
=
x
.
fakeData
().
Item1
;
customer_Templates
=
x
.
fakeData
().
Item2
;
Subdetails
=
x
.
fakeData
().
Item3
;
int
BODY
=
customer_Templates
.
FirstOrDefault
().
body
;
int
SEED
=
customer_Templates
.
FirstOrDefault
().
merge
;
//count sheet
var
_MAXSHEET
=
customer_Templates
.
Max
(
c
=>
c
.
sheet
);
var
firstSheet
=
0
;
//variable ?
ExcelPackage
.
LicenseContext
=
LicenseContext
.
NonCommercial
;
var
filePath
=
@"C:\Users\Admin\Downloads\HR_SK.xlsx"
;
byte
[]
file
=
File
.
ReadAllBytes
(
filePath
);
List
<
saved
>
XX
=
new
List
<
saved
>();
using
(
MemoryStream
stream
=
new
MemoryStream
(
file
))
{
using
(
ExcelPackage
excelPackage
=
new
ExcelPackage
(
stream
))
{
while
(
firstSheet
==
_MAXSHEET
)
{
var
DataSheet
=
excelPackage
.
Workbook
.
Worksheets
[
firstSheet
];
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
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
{
var
split
=
value
.
coordinate
.
Split
(
":"
);
int
countsub
=
4
;
//count list on db
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"
);
}
}
}
using
OfficeOpenXml
;
using
System
;
using
System.Collections
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
namespace
testImport
{
public
class
excel_template
{
public
Guid
id
{
get
;
set
;
}
public
string
name
{
get
;
set
;
}
public
string
code
{
get
;
set
;
}
public
string
type
{
get
;
set
;
}
}
public
class
customer_template
{
public
Guid
id
{
get
;
set
;
}
public
Guid
customer_id
{
get
;
set
;
}
public
Guid
id_excel_template
{
get
;
set
;
}
public
int
sheet
{
get
;
set
;
}
public
string
coordinate
{
get
;
set
;
}
public
int
order
{
get
;
set
;
}
public
Guid
id_sub
{
get
;
set
;
}
public
int
body
{
get
;
set
;
}
public
int
merge
{
get
;
set
;
}
}
public
class
subdetail
{
public
Guid
id
{
get
;
set
;
}
public
Guid
id_excel_template
{
get
;
set
;
}
public
int
row
{
get
;
set
;
}
}
public
class
saved
{
public
Guid
id
{
get
;
set
;
}
public
Guid
id_excel_template
{
get
;
set
;
}
public
Guid
user_id
{
get
;
set
;
}
public
string
value
{
get
;
set
;
}
public
DateTime
Time
{
get
;
set
;
}
public
DateTime
created
{
get
;
set
;
}
public
string
tmp
{
get
;
set
;
}
}
public
class
Program
{
public
static
void
Main
(
string
[]
args
)
{
List
<
excel_template
>
excel_Templates
;
List
<
customer_template
>
customer_Templates
;
List
<
subdetail
>
Subdetails
;
Data
x
=
new
Data
();
excel_Templates
=
x
.
fakeData
().
Item1
;
customer_Templates
=
x
.
fakeData
().
Item2
;
Subdetails
=
x
.
fakeData
().
Item3
;
int
BODY
=
customer_Templates
.
FirstOrDefault
().
body
;
int
SEED
=
customer_Templates
.
FirstOrDefault
().
merge
;
//count sheet
var
_MAXSHEET
=
customer_Templates
.
Max
(
c
=>
c
.
sheet
);
var
firstSheet
=
0
;
//variable ?
ExcelPackage
.
LicenseContext
=
LicenseContext
.
NonCommercial
;
var
filePath
=
@"C:\Users\Admin\Downloads\HR_SK.xlsx"
;
byte
[]
file
=
File
.
ReadAllBytes
(
filePath
);
List
<
saved
>
XX
=
new
List
<
saved
>();
using
(
MemoryStream
stream
=
new
MemoryStream
(
file
))
{
using
(
ExcelPackage
excelPackage
=
new
ExcelPackage
(
stream
))
{
while
(
firstSheet
==
_MAXSHEET
)
{
var
DataSheet
=
excelPackage
.
Workbook
.
Worksheets
[
firstSheet
];
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
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
{
var
split
=
value
.
coordinate
.
Split
(
":"
);
int
countsub
=
4
;
//count list on db
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
=
Subdetails
[
ii
].
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"
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment