Hi Spire,
I have tried the free spire.xls on nuget on my MVC project... I somehow manage to write a piece of code that gets the uploaded file pass it on the stream and then load it... Below is my code
[Model]
public class OrderHeader{
[Key]
public int id { get; set; }
public DateTime document_date { get; set; }
[NotMapped]
public string document_date_view { get { return document_date.ToShortDateString(); } }
public string document_number { get; set; }
public int? platform_id { get; set; }
public string agency_id { get; set; }
public string advertiser_id { get; set; }
public int account_executive_id { get; set; }
}
[Controller]
OrderController
public async Task<IActionResult> Import(IFormFile file)
{
using (var stream = new MemoryStream())
{
await file.CopyToAsync(stream);
Workbook wbs = new Workbook();
wbs.LoadFromStream(stream);
Worksheet wks = wbs.Worksheets[0];
var agen = wks.Range["C4:C4"];
var adver = wks.Range["C4:C4"];
var prod = wks.Range["C6:C6"];
var camp = wks.Range["C7:C7"];
var cont = wks.Range["D4:D4"];
var desg = wks.Range["D5:D5"];
var refn = wks.Range["D7:D7"];
var docdt = wks.Range["G4:G4"];
var isbill = wks.Range["G6:G6"];
OrderHeader ord = new OrderHeader
{
ord.document_date = docdt.Value2
};
}
The red line is in ord.document_date = docdt.Value();
How can I pass the value of my CellRange variable to my Model property?
I want to pass this to the model so that I can do the saving using SaveChanges function of MVC
Thank you!