3
3
using System . Web . Mvc ;
4
4
using Telerik . Documents . SpreadsheetStreaming ;
5
5
using Newtonsoft . Json ;
6
+ using ExportHelpers ;
7
+ using System . Collections . Generic ;
6
8
7
9
namespace GridExcelSpreadProcessing . Controllers
8
10
{
@@ -15,7 +17,7 @@ public ActionResult Index()
15
17
16
18
public JsonResult Export ( string model , string data , string format , string title )
17
19
{
18
- var modelObject = JsonConvert . DeserializeObject < dynamic > ( model ) ;
20
+ var modelObject = JsonConvert . DeserializeObject < IList < ColumnSettings > > ( model ) ;
19
21
var dataObject = JsonConvert . DeserializeObject < dynamic > ( data ) ;
20
22
21
23
SpreadDocumentFormat exportFormat = format == "CSV" ? SpreadDocumentFormat . Csv : SpreadDocumentFormat . Xlsx ;
@@ -30,7 +32,7 @@ public JsonResult Export(string model, string data, string format, string title)
30
32
for ( int idx = 0 ; idx < modelObject . Count ; idx ++ )
31
33
{
32
34
var modelCol = modelObject [ idx ] ;
33
- string columnName = modelCol . title ?? modelCol . field ;
35
+ string columnName = modelCol . Title ?? modelCol . Field ;
34
36
using ( ICellExporter cell = row . CreateCellExporter ( ) )
35
37
{
36
38
cell . SetValue ( columnName ) ;
@@ -45,7 +47,7 @@ public JsonResult Export(string model, string data, string format, string title)
45
47
{
46
48
using ( ICellExporter cell = row . CreateCellExporter ( ) )
47
49
{
48
- cell . SetValue ( dataObject [ rowIdx ] [ modelObject [ colIdx ] . field . ToString ( ) ] . ToString ( ) ) ;
50
+ cell . SetValue ( dataObject [ rowIdx ] [ modelObject [ colIdx ] . Field ] . Value ) ;
49
51
}
50
52
}
51
53
}
0 commit comments