Closed direstrepo24 closed 6 years ago
@direstrepo24 The Excel export package is not available in the trial version. I am sorry about that. Please allow me some time to see whether we can make it available for you. I will let you know soon.
@direstrepo24 You should be able to install the DotVVM.BusinessPack.Export.Excel
package including the GridViewExportExcel
class. Please let me know how it works for you.
Hi, get this warning: 'DotVVM.BusinessPack.Export.Excel 1.1.5-rc1' was restored using '.NETFramework,Version=v4.6.1' instead of the project target framework '.NETCoreApp,Version=v2.0'. This package may not be fully compatible with your project.
Excel export depends on System.Drawing
and requires full .NET Framework running on Windows. Your application should target net451
or higher. It may also work on Mono, but it is not tested.
For now, it doesn't work in xplat .NET Core applications. We will definitely fix that in future releases.
thanks, us working new project with asp.net core and i need implement with this library. Is there any solution for now, otherwise to export to excel?
I am afraid I can't help you right now. We are going to make the Excel export xplat when the EPPlus or any similar library is compatible with System.Drawing.Common
.
ok, thanks.
@direstrepo24 Can you use CSV export instead of Excel export?
@djanosik What about CoreCompat.System.Drawing
?
@tomasherceg I would rather not take a dependency on this library. Official cross-platform System.Drawing
is already available on NuGet.
the idea is generate a report in excel. I can place in a button event of dotvvm call a function of for example Epplus or another library to export to excel? Could you give me a simple example? This is important because all applications and businesses are based on reports. thanks
I am not sure I understand. You can generate the Excel file yourself with any library you want. Or you can use our CSV export for now. CSV files can also be opened in Excel.
excuseme, what is your .cvs export, any example?
It works the same way as GridViewExportExcel
. You just need to use GridViewExportCsv
class from the DotVVM.BusinessPack.Export.Csv
package.
var exporter = new GridViewExportCsv<Customer>(new GridViewExportCsvSettings<Customer> { Separator = ";" });
var gridView = Context.View.FindControlByClientId<DotVVM.BusinessPack.Controls.GridView>("data", true);
using (var file = exporter.Export(gridView, Customers))
{
Context.ReturnFile(file, "Report.csv", "text/csv");
}
Hi, have this exception:
an exception of type 'DotVVM.Framework.Controls.DotvvmControlException' occurred in DotVVM.Framework.dll but was not handled in user code: 'The control with ID 'data' was found, however it is not an instance of the desired type 'DotVVM.BusinessPack.Controls.GridView'.'
at DotVVM.Framework.Controls.DotvvmControl.FindControlByClientId[T](String id, Boolean throwIfNotFound), my page is: <dot:GridView ID="data" DataSource="{value: Customers}" InlineEditing="true" >
and button event is: <dot:Button Text="Export" Click="{command: Export()}" />
You need to use <bp:GridView ...>
in markup code instead of <dot:GridView ...>
.
Excuseme, i follow this example https://www.dotvvm.com/docs/controls/businesspack/GridView/latest , in the public BusinessPackDataSet
Yes, the docs are written for newer version than you have. Try to use BpGridViewDataSet
.
Excuseme, last question, i have excepction to load data: 'System.NullReferenceException' occurred in DotVVM.BusinessPack.Export.dll but was not handled in user code: 'Object reference not set to an instance of an object.'
this ocurred in line --->:
` public void Export()
{
var exporter = new GridViewExportCsv
(exception) ---> using (var file = exporter.Export(gridView, Customers)) { Context.ReturnFile(file, "Report.csv", "text/csv"); } }`
Thanks for you helpme.
Show me the stack trace. Where is the exception thrown?
in line: using (var file = exporter.Export(gridView, Customers))
I don't think it's possible. Show me the stack trace.
excepción: CLR/System.NullReferenceException
An exception of type 'System.NullReferenceException' occurred in DotVVM.BusinessPack.Export.dll but was not handled in user code: 'Object reference not set to an instance of an object.'
at DotVVM.BusinessPack.Export.GridViewExportBase1.GetOrderedGridViewUserSettings(GridView gridView) at DotVVM.BusinessPack.Export.Csv.GridViewExportCsv
1.Export(GridView gridView, GridViewDataSet`1 dataSet)
at electroweb.ViewModels.ViewModelCustomer.Export() in /Users/torrefuertesas/dev/electro/electroweb/ViewModels/ViewModelCustomer.cs:line 75
at DotVVM.Framework.Binding.Expressions.CommandBindingExpression.Evaluate(DotvvmBindableObject control, DotvvmProperty property, Object[] args)
at DotVVM.Framework.Runtime.Commands.CommandResolver.<>cDisplayClass10.
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 96.372ms 200 text/javascript
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]
Request starting HTTP/1.1 POST http://localhost:5000/
Can you please format the stack trace to make it readable? Or just post a screenshot?
I use Spa page, and button "Export":
" at DotVVM.BusinessPack.Export.GridViewExportBase
1.GetOrderedGridViewUserSettings(GridView gridView)\n at DotVVM.BusinessPack.Export.Csv.GridViewExportCsv1.Export(GridView gridView, GridViewDataSet
1 dataSet)\n at electroweb.ViewModels.ViewModelCustomer.Export() in /Users/torrefuertesas/dev/electro/electroweb/ViewModels/ViewModelCustomer.cs:line 75\n at lambda_method(Closure )\n at DotVVM.Framework.Binding.Expressions.CommandBindingExpression.Evaluate(DotvvmBindableObject control, DotvvmProperty property, Object[] args)\n at DotVVM.Framework.Runtime.Commands.CommandResolver.<>c__DisplayClass1_0.
Try to set the UserSettings
property on the GridView
to a GridViewUserSettings
instance you create in your ViewModel.
Excuse me, do not you understand can you give me some code?
It's explained in docs: https://www.dotvvm.com/docs/controls/businesspack/GridView/latest
The property is called UserSettings
. Take a look at docs please.
Hi, i have this error, set Usersetting, but :
I used spa page,
Ok, see this issue: https://github.com/riganti/dotvvm/issues/426
i see this:
This is probably unrelated to DotVVM or this issue. How does the stack trace look?
and :
Hmm, I need stack trace of the "Timeouts are not supported on this stream." exception.
I can't read the stack trace. But if this is where the exception is thrown, it's not a problem at all. You are accessing unsupported properties in debugger. Or is it also thrown at runtime? Please, try to make it easier for me to help you.
hi, thanks for you help, this in time execution, when click in Export, go to the viewModel this :
I've already told you the DotvvmInterrupRequestExecutionException
should be thrown. It's not an issue. Are you able to download the returned file or not?
no, it goes to the exception:
I know and it's the correct behavior. Please, turn off the debugger and try to download the file.
Ready, it ok. Thanks
Use dotnet run
from command line. Or just skip the exception and continue.
This seems to be outdated Can you provide documentation or sample code that is updated?
@CharanSaradaSSD Hi, which version of Bussiness Pack are you using? I will provide you with the sample code for the version. We are currently working on better documentation for the export but it is not ready yet.
@CharanSaradaSSD Hi, which version of Bussiness Pack are you using? I will provide you with the sample code for the version. We are currently working on better documentation for the export but it is not ready yet.
2.5.3
2.5.3 This is the version I am working on
@CharanSaradaSSD This code should do the trick. Just put it inside of your command and it will generate the Excel file and return it to the user.
public class GridViewExportViewModel : DotvvmViewModelBase
{
private readonly BindingCompilationService bindingService;
public BusinessPackDataSet<CustomerData> CustomersDataSet { get; set; } = new BusinessPackDataSet<CustomerData>() { PagingOptions = { PageSize = 5 } };
public GridViewExportViewModel(BindingCompilationService bindingService)
{
this.bindingService = bindingService;
}
public void Export()
{
var gridView = Context.View.FindControlByClientId<BusinessPack.Controls.GridView>("CustomersGridView", true);
var gridViewExportExcel = new GridViewExportExcel<CustomerData>(bindingService);
using (var exportStream = gridViewExportExcel.Export(gridView, customersDataSet))
{
Context.ReturnFile(exportStream, "export.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
}
}
}
Just a note: In version 3.0.0 we have managed to make the Excel export much better. It provides support for all of Excel data types and extensibility points.
Right now the 3.0.0 version is in preview, but the Excel export should be stable. We are currently working on the documentation for it so it should be available soon.
How i can export to excel?, as in the example of "Bussines Editor" in https://themes.dotvvm.com/editor, i tried:
but I can not find the space name "GridViewExportExcel", i have Bussinespack trial version. help me please?