We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

ImportData

Thread ID:

Created:

Updated:

Platform:

Replies:

121724 Jan 19,2016 03:50 PM Jan 22,2016 02:04 AM Windows Forms 6
loading
Tags: XlsIO
Constantin Constantinescu
Asked On January 19, 2016 03:50 PM

Hello,

I am trying to import data from my database to a worksheet. I'm using EF6 to bring the data.

list = new SortableBindingList<Document>();
Context.Documents.Where(p =>
                (p.CreatedOn >= startdt && p.CreatedOn < enddt) &&
                (p.TemplatePath.ToLower().Contains(DocsFilter) ||
                 p.Name.ToLower().Contains(DocsFilter) ||
                 p.Comments.ToLower().Contains(DocsFilter))
              ).ToList().ForEach(p => list.Add(p)); 

ExcelEngine excelEngine = new ExcelEngine();

            IApplication application = excelEngine.Excel;
            application.DefaultVersion = ExcelVersion.Excel2013;
            IWorkbook workbook = application.Workbooks.Create(1);
            IWorksheet worksheet = workbook.Worksheets[0];
           
         
            IList<Document> docs = list
         
            worksheet.ImportData(docs, 2, 1, false);

            workbook.SaveAs("E:\\temp\\Output\\Spre.xlsx");

I don't know why but I do not get the data in Excel. 

Thank you in advance!
Costin

Abirami Varadharajan [Syncfusion]
Replied On January 20, 2016 07:00 AM

Hi Constantin,

We are unable to reproduce the reported issue while importing a data from datatable. We have shared a sample illustrating how to import a data from datatable which can be downloaded from following link.
Sample link http://www.syncfusion.com/downloads/support/directtrac/general/ze/ImportData-386617835.zip

If you are still able to reproduce the issue then please share us the issue reproducing sample which will be helpful for us to give a prompt solution at the earliest.

Regards,
Abirami.

Abirami Varadharajan [Syncfusion]
Replied On January 20, 2016 07:39 AM

Hi Constantin


You can also refer our below UG documentation link to know more about importing data in XlsIO.


UG Documentation link: http://help.syncfusion.com/file-formats/xlsio/working-with-data#importing-data-to-worksheets


Regards,

Abirami.


Constantin Constantinescu
Replied On January 20, 2016 05:59 PM

Hi Abirami,

Thank you for your reply. I changed a little the way of implementing it. I was abletu adapt my code and use ImportDataTable.

Regards, 
Constantin

Abirami Varadharajan [Syncfusion]
Replied On January 20, 2016 11:35 PM

Hi Constantin,


We are glad to know that the issue has been resolved. Please let us know if you need any further assistance on this.

Regards,
Abirami.


Constantin Constantinescu
Replied On January 21, 2016 05:04 AM

Hi,

I would also like to know how cand I show a SaveAs Dialog for my Excel Workbook.

 ExcelEngine excelEngine = new ExcelEngine();
            IApplication application = excelEngine.Excel;
            application.DefaultVersion = ExcelVersion.Excel2013;
            IWorkbook workbook = application.Workbooks.Create(1);
            IWorksheet worksheet = workbook.Worksheets[0];
            worksheet.ImportDataTable(dt, true, 1, 1, true);
workbook.SaveAs("E:\\temp\\Output\\Spreadsheet.xlsx");

I want to let the user choose about name and where to save the Excel Document.

Regards,
Constantin

Abirami Varadharajan [Syncfusion]
Replied On January 22, 2016 02:04 AM

Hi Constantin,

Yes, you can save the workbook in any location using SaveAsDialog. We have shared a sample illustrating this behaviour which can be downloaded from following link.


Sample link:
http://www.syncfusion.com/downloads/support/directtrac/general/ze/SaveFile-381635603.zip

Please let us know if you have any concerns on this.

Regards,

Abirami.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;