Using the C1FlexGrid Control > Saving, Loading, and Printing. The C1FlexGrid control has methods that allow you to save, load, and print grids. See Also. The sample demonstrates how to export or import FlexGrid content to/from an Excel xlsx file. To export FlexGrid content, pass the FlexGrid instance to the. This section shows how to call the Web API service project through a client application and add export function for exporting FlexGrid data as an excel.
|Published (Last):||27 September 2007|
|PDF File Size:||6.73 Mb|
|ePub File Size:||20.36 Mb|
|Price:||Free* [*Free Regsitration Required]|
The author has received compensation from ComponentOne for the following article: Specifically, it will demonstrate importing and exporting Microsoft Excel files.
FlexGridPdfConverter and PdfDocument Explorer | Wijmo
The sample project expands on the Expense Report application covered in the article: When we open the application, we can create a new report, vlexgrid open an existing one, by selecting it on the Dashboard screen.
We can click the Export Ex;ort Excel button to open the report on the Excel screen. When the report opens on the Excel screen in the ExcelBook control that implements the ComponentOne FlexGrid controlwe notice that it implements Excel formatting and formulas.
We can open the file in Microsoft Excel and add, edit, and remove data. We can return to the LightSwitch application and open the Excel file.
Any changes to the Excel file will show, and we can make further edits in the control if needed. When we click Importcustom code determines if this is an existing report to update or a new report to insert based on the report name, report date, and the user importing the report. When the data is imported, we see that all normal LightSwitch business rules are processed.
It will automatically create shortcuts in our Windows Start Menu. We select Samples under Studio for Silverlight. When we launch the ExcelBook solution and load a sample Excel report, we see that it implements the ComponentOne FlexGrid for Silverlight control to display the Excel files. The ExcelBook sample contains a number of features such as filtering, sorting, grouping, copy and paste, redo and undo, and printing.
One of the most fascinating things about this sample componentoe how it implements the Calculation Engine that allows the FlexGrid control to implement Excel formulas. The Calculation Engine is covered in detail here: We also add references to the C1.
As covered in the article: ComponentOne Schedulerwe create a public property in the code behind of the Silverlight control to enable programmatic access of the control in LightSwitch. In the sample download, we have implemented a New Report button on the Excel screen.
This creates a blank expense report that, for example, could be given to employees to complete when they are on the road and may not have access to the LightSwitch application.
We must create the Excel spread sheet using that class and then load it into the C1FlexGridBook object that displays the spread sheet.
When componnetone open an existing Excel file and ot the Import button, we need to determine if it is an existing report or a new one. If it is an existing report we need to update the report. We attempt to locate the report, and if we cannot find it, we create a new one; otherwise, we open the compknentone report and delete all the coponentone expense items:. Finally, we open the report in the Report Details screen or switch to it if it is already openand refresh the data in case the screen is already flexgriv.
The final feature we will implement will allow us to open an existing expense report record and export it to the ExcelBook control. We ensure that Is Required is not checked because we still want to allow the option to open the screen without passing an ExpenseReportID. We also add an ExpenseReport entity and an associated ReportDetails collection to the screen. It is important that we add this entity and collection to the screen so that the LightSwitch code that we will create will have entities and collections to use componenntone loading the data.
While it is possible to load the data using entities flexyrid collections created entirely in code, we will run into challenges related to componentpne dual-threading that LightSwitch uses to process user interface code and background processes. Adding the entities and collections to the screen and hydrating them provides less friction when implementing our custom code. I have found that without implementing this in the InitializeDataWorkspace method, the report details would not load, even when you implement code in other methods to explicitly load the data.
The operation to open the Excel screen and load a spread sheet requires us to interact with the ExcelBook control without the normal process of having a screen fully load and waiting for an end-user to click a button. We must wire-up a method to notify us when the screen is loaded and the ExcelBook that implements the FlexGrid control is available:. The LoadExpenseReport method resembles the New Report code with this additional code to gather the expense details:.
The code required for the Export To Flexgrdi button on the Excel screen is very simple:. The ComponentOne ExcelBook is a feature-rich control that still requires a considerable amount of back-end features to be implemented to process the Excel files that it loads. Using it with LightSwitch allows us to implement these requirements in a fraction of the time because most of the required features, such as screen management and saving and loading records from the database, are already built-into LightSwitch.
Online help for ComponentOne Excel: There are so many opportunities with LightSwitch, and it’s contributions like this that make it easy to answer those, ” By the way, I love the use of the FlexGrid with grouping and hyperlinks. This may be your best article yet Michael – another phenomenal way to show how powerful Lightswitch is, especially when combined with the tools from a company as great as ComponentOne!
If I may ask for more, is there a VB version of the code? Home Blog Downloads Market.
Client: MindManager causes iGrafx crashes (Component One or VSFlexGrid errors)
Custom ControlsApplications. Blogs LightSwitch Help Website. Enter the code shown above in the box below.
Either way it reaches new levels of awesomeness! Using the ComponentOne Excel for Silverlight Control with LightSwitch This may be your best article yet Michael – another phenomenal way to show how powerful Lightswitch is, especially when combined with the tools from a company as great as ComponentOne! Optional Email used only to show Gravatar. Security Code Enter the componenfone shown above in the box below.