6
6
using System . Collections . Generic ;
7
7
using System . IO ;
8
8
using System . Linq ;
9
+ using ClosedXML . Report . Excel ;
9
10
using Xunit ;
10
11
using Xunit . Abstractions ;
11
12
@@ -87,8 +88,9 @@ public void Add_enumerable_variable_should_fill_range()
87
88
} ) ,
88
89
wb =>
89
90
{
91
+ wb . SaveAs ( ".\\ Output\\ 4.xlsx" ) ;
90
92
var sheet = wb . Worksheet ( 1 ) ;
91
- sheet . Cell ( "G1 " ) . GetValue < string > ( ) . Should ( ) . Be ( "title from test" ) ;
93
+ sheet . Cell ( "H1 " ) . GetValue < string > ( ) . Should ( ) . Be ( "title from test" ) ;
92
94
sheet . Cell ( "B4" ) . GetValue < string > ( ) . Should ( ) . Be ( "1" ) ;
93
95
sheet . Cell ( "B5" ) . GetValue < string > ( ) . Should ( ) . Be ( "2" ) ;
94
96
sheet . Cell ( "B6" ) . GetValue < string > ( ) . Should ( ) . Be ( "3" ) ;
@@ -101,24 +103,27 @@ public void Add_enumerable_variable_should_fill_range()
101
103
sheet . Cell ( "E4" ) . GetValue < int > ( ) . Should ( ) . Be ( testData [ 0 ] . Age ) ;
102
104
sheet . Cell ( "E5" ) . GetValue < int > ( ) . Should ( ) . Be ( testData [ 1 ] . Age ) ;
103
105
sheet . Cell ( "E6" ) . GetValue < int > ( ) . Should ( ) . Be ( testData [ 2 ] . Age ) ;
104
- sheet . Cell ( "F4" ) . GetValue < string > ( ) . Should ( ) . Be ( testData [ 0 ] . Address . City ) ;
105
- sheet . Cell ( "F5" ) . GetValue < string > ( ) . Should ( ) . Be ( testData [ 1 ] . Address . City ) ;
106
- sheet . Cell ( "F6" ) . GetValue < string > ( ) . Should ( ) . Be ( testData [ 2 ] . Address . City ) ;
107
- wb . NamedRange ( "PlanData" ) . Ranges . First ( ) . RangeAddress . ToStringRelative ( ) . Should ( ) . Be ( "A4:J6" ) ;
108
- sheet . Cell ( "G4" ) . GetValue < int > ( ) . Should ( ) . Be ( testData [ 0 ] . Hours [ 0 ] ) ;
109
- sheet . Cell ( "G5" ) . GetValue < int > ( ) . Should ( ) . Be ( testData [ 1 ] . Hours [ 0 ] ) ;
110
- sheet . Cell ( "G6" ) . GetValue < int > ( ) . Should ( ) . Be ( testData [ 2 ] . Hours [ 0 ] ) ;
111
- sheet . Cell ( "H4" ) . GetValue < int > ( ) . Should ( ) . Be ( testData [ 0 ] . Hours [ 1 ] ) ;
112
- sheet . Cell ( "H5" ) . GetValue < int > ( ) . Should ( ) . Be ( testData [ 1 ] . Hours [ 1 ] ) ;
113
- sheet . Cell ( "H6" ) . GetValue < int > ( ) . Should ( ) . Be ( testData [ 2 ] . Hours [ 1 ] ) ;
114
- sheet . Cell ( "I4" ) . GetValue < int > ( ) . Should ( ) . Be ( testData [ 0 ] . Hours [ 2 ] ) ;
115
- sheet . Cell ( "I5" ) . GetValue < int > ( ) . Should ( ) . Be ( testData [ 1 ] . Hours [ 2 ] ) ;
116
- sheet . Cell ( "I6" ) . GetValue < int > ( ) . Should ( ) . Be ( testData [ 2 ] . Hours [ 2 ] ) ;
117
- sheet . Cell ( "J4" ) . GetValue < int > ( ) . Should ( ) . Be ( testData [ 0 ] . Hours . Sum ( ) ) ;
118
- sheet . Cell ( "J5" ) . GetValue < int > ( ) . Should ( ) . Be ( testData [ 1 ] . Hours . Sum ( ) ) ;
119
- sheet . Cell ( "J6" ) . GetValue < int > ( ) . Should ( ) . Be ( testData [ 2 ] . Hours . Sum ( ) ) ;
106
+ sheet . Cell ( "F4" ) . FormulaA1 . Should ( ) . Be ( $ "HYPERLINK(\" mailto:{ testData [ 0 ] . Email } \" ,\" { testData [ 0 ] . Email } \" )") ;
107
+ sheet . Cell ( "F5" ) . FormulaA1 . Should ( ) . Be ( $ "HYPERLINK(\" mailto:{ testData [ 1 ] . Email } \" ,\" { testData [ 1 ] . Email } \" )") ;
108
+ sheet . Cell ( "F6" ) . FormulaA1 . Should ( ) . Be ( $ "HYPERLINK(\" mailto:{ testData [ 2 ] . Email } \" ,\" { testData [ 2 ] . Email } \" )") ;
109
+ sheet . Cell ( "G4" ) . GetValue < string > ( ) . Should ( ) . Be ( testData [ 0 ] . Address . City ) ;
110
+ sheet . Cell ( "G5" ) . GetValue < string > ( ) . Should ( ) . Be ( testData [ 1 ] . Address . City ) ;
111
+ sheet . Cell ( "G6" ) . GetValue < string > ( ) . Should ( ) . Be ( testData [ 2 ] . Address . City ) ;
112
+ wb . NamedRange ( "PlanData" ) . Ranges . First ( ) . RangeAddress . ToStringRelative ( ) . Should ( ) . Be ( "A4:K6" ) ;
113
+ sheet . Cell ( "H4" ) . GetValue < int > ( ) . Should ( ) . Be ( testData [ 0 ] . Hours [ 0 ] ) ;
114
+ sheet . Cell ( "H5" ) . GetValue < int > ( ) . Should ( ) . Be ( testData [ 1 ] . Hours [ 0 ] ) ;
115
+ sheet . Cell ( "H6" ) . GetValue < int > ( ) . Should ( ) . Be ( testData [ 2 ] . Hours [ 0 ] ) ;
116
+ sheet . Cell ( "I4" ) . GetValue < int > ( ) . Should ( ) . Be ( testData [ 0 ] . Hours [ 1 ] ) ;
117
+ sheet . Cell ( "I5" ) . GetValue < int > ( ) . Should ( ) . Be ( testData [ 1 ] . Hours [ 1 ] ) ;
118
+ sheet . Cell ( "I6" ) . GetValue < int > ( ) . Should ( ) . Be ( testData [ 2 ] . Hours [ 1 ] ) ;
119
+ sheet . Cell ( "J4" ) . GetValue < int > ( ) . Should ( ) . Be ( testData [ 0 ] . Hours [ 2 ] ) ;
120
+ sheet . Cell ( "J5" ) . GetValue < int > ( ) . Should ( ) . Be ( testData [ 1 ] . Hours [ 2 ] ) ;
121
+ sheet . Cell ( "J6" ) . GetValue < int > ( ) . Should ( ) . Be ( testData [ 2 ] . Hours [ 2 ] ) ;
122
+ sheet . Cell ( "K4" ) . GetValue < int > ( ) . Should ( ) . Be ( testData [ 0 ] . Hours . Sum ( ) ) ;
123
+ sheet . Cell ( "K5" ) . GetValue < int > ( ) . Should ( ) . Be ( testData [ 1 ] . Hours . Sum ( ) ) ;
124
+ sheet . Cell ( "K6" ) . GetValue < int > ( ) . Should ( ) . Be ( testData [ 2 ] . Hours . Sum ( ) ) ;
120
125
sheet . Cell ( "D8" ) . GetValue < int > ( ) . Should ( ) . Be ( 15 ) ;
121
- sheet . Cell ( "K6 " ) . GetValue < int > ( ) . Should ( ) . Be ( 4 ) ;
126
+ sheet . Cell ( "L6 " ) . GetValue < int > ( ) . Should ( ) . Be ( 4 ) ;
122
127
} ) ;
123
128
}
124
129
0 commit comments