Dear All,
I require assistance
regarding the following feature for a web application (written in NET4.8 using
MVC). A background job downloads a spreadsheet. Next, I am reading the
spreadsheet into a data table using Syncfusion.XlsIO. The data table created is used as data source for pdf file. I am using Syncfusion.Pdf and Syncfusion.Pdf.Tables for processing the data table. This has been
working well so far and I managed to create a dummy report that is automatically
downloaded, if the button on the dummy page is clicked (I am currently creating
a working prototype).
Be that as
it may, I need to save the report to a database, since it is required that users
should be able to download reports from previous months/years etc. (cf. mock-up
attached).
I am using EntityFramework. My current approach was to save
the report as byte[] using the following model:
public class Report
{
public
int Id { get; set; }
public
byte[] Content { get; set; }
public
string FileName { get; set; }
public
DateTime ReportCreatedAt { get; set; }
public
DateTime FileDate { get; set; }
}
However, I
cannot figure out how to add the report created to the model for saving said
model to the database for later retrieval. Of course, the model can be changed
according to your suggestions. As previously mentioned, I am not sure how to
handle the database part for the report (CRUD operations). Please do take a look at the code snippets attached.
Would be
grand if you could help me out here. Looking forward to your suggestions. Please do get in touch if you require additional information
Thanks a
mil in advance
C.
Dear Gowthamraj K,
Thanks a
mil for your reply and the link to the SF documentation. Sorry if my initial
description was insufficient.
I already
managed to apply the steps mentioned in the documentation. My issue is how to
persist / save either the entire pdf document, spreadsheet or the data table
(containing the data extracted from the spreadsheet) to a database. The reason
being that there is a table in one of the views (cf. drawing attached when
creating this post). Depending on which button the user clicks in one of the
table rows, the report is generated. Since I did not wish to create the report
from scratch each time the button is clicked, I thought I best save said
reports to a database to retrieve them if required.
It is true that the sample codes point out how to generate different file formats from different sources, but I am interested in how I could persist those files instead of generating them from scratch.
I am currently storing the data table extracted from the spreadsheet into a byte array, which is then saved to a data table column. However, I am loosing the column headers when converting the byte array back to a data table object. I have attached a code snippet outlining my approach.
To rephrase my requirement(s): How could I either save the complete PDF document, the spreadsheet or the data table extracted from said spreadsheet to a database for later retrieval / reuse without having to generate each report from scratch if users wish to download a report.
Or would you suggest I'd rather not take this approach and generate the report from scratch each time? Please do net hesitate to get back in touch if you require additional information. Thanks a mil in advance for your support.
Looking forward to hearing from you.
Kind regards