how to fill xlsx template whith dynamic data to generate chart by NPOI? - c#

I have a .xlsx file which contain a chart as a report template. I create a table manually as the data source of the chart. What I want to do is to fill the table with data so that the chart I inserted will change respectively, the data is dynamic.
The problem I met is the same as the link below:
"The new row we just added wasn’t included in the table. The chart that is linked to the table won’t update because it isn’t aware of the new row".
(https://www.leniel.net/2009/10/npoi-with-excel-table-and-dynamic-chart.html)
image that show the problem
The solution in this website is to extend table manually in excel app.I have thousands of data row to insert so the solution is not suitable for me.
Is there any methods to extend table by code?

Related

Datagridview column type

We did not create columns visually in the DataGridView of form application. We get the data from XML and it creates the columns according to XML. We want the 5th column you see in the picture to be a progress bar. How do we do this in the codes you see below?
Here image i need to add code blocks
If needed i can share all of project files. Thank you

How to add a table row to a word document using syncfusion in C#

I am very new to syncfusion and I am kind of stuck with this problem. I can easily populate a table if all of the rows and cells are created but I run into 'IndexOutofBounds' error once my data exceeds the number of rows in my template table. How can I add a row to a growing template table using Syncfusion in C#? I also would like to know how to handle the possiblity of the table growing to more than one page.
Adding a row is an easy task. After adding the row the cell paragraphs have to be added and formatted. That was the error I was running into.
IWTable table = new IWTable();
table.AddRow(True);
table.Rows[0].Cells[0].AddParagraph().AddText("sample text");
If you know the exact number of rows and columns, then you can utilize the below code to define rows and columns for a table.
IWTable table = document.LastSection.AddTable();
table.ResetCells(10, 4);
If you are not sure about the number of rows then you can use the below code to add a row dynamically.
table.AddRow();

How to add the data source to the rdlc file in visual studio 2010?

I am new to windows desktop application development.
I want to generate a bill report that is the bill master details should be displayed once and the related items should be displayed in the tabular format.
I have created the data table in dataset. The data table is configured.
Now in the report design I am not able to see this table to drag the field to their proper position.
Please help how to do so.
Thanks in advance.
Adding datasets
First you have to add a Data Source in your Report. You can do this by using the Data Sources window in VS. Click the Add new data source and select what you want (I usually use object). In the Report Data window there is a folder 'Datasets'. If you right-click it you can add a dataset.
Data in a table
To visualize the dataset you can drag a Table from your Toolbox onto the report, select it, then right-click on the upper-left corner and select Tablix Properties. There you can bind a Dataset to the table. Choose which items you want to display in which column by clicking on the column and selecting a value.
Singular data (textbox)
You can set an expression on a textbox that retrieves a specific set of data from a dataset (you can also use this on table columns btw). You can do this by right-clicking the textbox en going to Expression. This will open up an Expression window that contains some sort of expression builder.
The expression I use to retrieve singular data is the following (not sure if this is the best approach but it's the only one I know):
First(Fields!MyField.Value, "MyDatasetName")
Basically I'm assuming there is only one row in my dataset (or that field is the same in all rows) so I'm just retrieving the first value.

How to avoid duplicate entries of a record when Exporting SQL server data to an Excel in C#?

I have requirement to export SQL Script data to an excel using C#.Net.
Currently I face issue in avoiding duplicat values for columns, when a record has multiple values for a column it should look like as in the bellow, the entire record should not repeated for each values of the column.
should I handle it in application level or in Sql script. please advice me.
Currently I get data set and bind it to a grid view and then do the export to excel function.
for example Sql Data could be
select B.BID, B.BName, M.Year
from tbl_B B
inner join tbl_Master M ON B.BID = fm.BIDFK
where B.BName = 'B9'
Group By B.BID, B.BName, M.Year
And the Result
I have cleared out this issue on C# side, I use nested grid-view to bind multiple valued columns for a record, when exporting to excel clear controls inside the parent grid-view to export data from all grid-view.
I think it need to be done in SQL script.
It's not complicated logic to apply .
I would seriously look at using the Report Viewer control and a local report rather than trying to build the Excel sheet by hand. Check out GotReportViewer.com and the examples on the right cover exporting to Excel, and using the control from a console application.

Create PivotTable programmatically

Using C# and OWC 11.0, I need to create an Excel output with all Raw Data in one sheet then, using that data as the connection string, create pivot tables in another worksheet. This Excel sheet will be downloaded by the end user so they can change parameters in the pivot table and get the report they need. Whenever the raw data is updated, the user will come to dashboard and get the new Excel generated.
I have the code for getting all the data into the data sheet. How might I set about creating the pivot table on the second work sheet?

Categories

Resources