What should be the docx template to put two XML fields in one column using OpenXmlPowerTools - c#

In my project we are generating reports using OpenXmlPowerTools by passing XML to DocumentAssembler.AssembleDocument method.
Everything works fine. Currently this is the table template in my .docx file
Now, I have added one more field to the rpt_ProformaInvoiceReportResult, but I do not want to show this new field in a new column in the table but in the existing column Equipment Number, so I tried this,
But this does not work. It never shows the SystemNumber value.
It does work when I create a new column and put this new field to that new column.
So looks like the template only binds one Xml field to one column.
Is there any way to achieve what I am trying to do?
That is putting FullEquipmentNumber and SystemNumber fields in one single column

Related

Adjust table adapter on Win Form to allow an expression

I have a form with a Data Grid View for personnel assigned to a project. I currently have a singular drop down that allows you to add people to the project which pulls all names of people based on a main roster. I figured out how to do this by editing the columns properties and using DisplayMember however, it only allows for one column selection and not an expression.
We have only a couple of people with the same last name however, it's caused headaches in the past. I want the drop down to pull in last name, first name. I've read a few things like using an expression property but haven't be able to find that. It seems a bit different than other posts I've read mainly because Visual Studio created Binding Sources and Table Adapters and I can't seem to edit this individual control column. Everything I've read shows how to do this by programatically creating a table but not by editing an existing one. I have an SQL view set up that solves this but am unable to set the control to a view or another query. So what's the best way to edit the adapter without creating the column on the actual table?
Thanks for any help.
Don
Followed this but wasn't able to get it to work with the DataGridView and adpaters.
https://learn.microsoft.com/en-us/dotnet/api/system.data.datacolumn.expression?redirectedfrom=MSDN&view=netframework-4.7.2#System_Data_DataColumn_Expression
This hasn't really got anything to do with the grid or the table adapter, so that would explain why you can't find it. Expression is a property of a DataColumn, i.e. a column in a DataTable, so that's where you need to make the change. If you have a typed DataSet then you make changes to it in the DataSet designer.
Open your DataSet in the designer. Right-click the appropriate table and select Add -> Column. Enter the name of the column in the table, then open the Properties window and set the Expression property. I just tested with a Person table with GivenName and FamilyName columns, adding a FullName column and setting the Expression to GivenName + ' ' + FamilyName. Once you save that, you can see in the Data Sources window that your table now has the extra column. If you drag that table onto a form, it will create a DataGridView with a corresponding column. If you already have a DataGridView then you can add a new column yourself and set its DataPropertyName so it binds to your new expression column.

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

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?

how to fill Dataset with custom built DataTable using c#?

I have to make a report.rdlc where i have to pass a dataset to it
I have DataTable made using C# not SQLDATAADAPTER other wise it can be filled as
adpt.fill(ds);
but i have only custom built DataTable using c# having columns and rows
How to make it datasource of report or make it dataset
Actually Simple... A Dataset is nothing but a collection of "DataTable" instances. You should be able to do via..
var DS = new DataSet();
YourCustomPopulatedDataTable.TableName = "SomeTable";
DS.Tables.Add( YourCustomPopulatedDataTable );
What * have done was created a baseline "ReportManager" class, but after I get the dataset with data back, I Write the XML output but also the XSD something like
DS.WriteXmlSchema( "MyXYZReport.xsd"); // the report will get this in a moment
DS.WriteXml( "MyXYZReport.xml");
Then, modify your project and add the ".xsd" file created so you don't have to fat-finger the schema for the report. So, the first time through, I query the data, generate the XSD/XML and stop before the actual report. Then, modify the project and add the XSD to it.
Now, open your rdlc. On the left-side you should have a panel for "Report Data". If not, click anywhere within your report, but not a specific object. Just enough to give focus you are working with the .RDLC. Then, click on "View" from the menu and the last item should show "Report Data" option. Once that is displayed, it will show how / where data comes from, parameters, images, data sources, data sets, etc.
Click on DataSets, right-click to Add Dataset and pick the .XSD you added to your project. This will display a dialog prompting with a "Name" to refer as in the report, then a data source. The Data Source should list the name such as "MyXYZReport". Under that will be "Available Datasets" and have the name of the tables within your dataset. Notice the one line change I did above to "name" the table before writing the XSD. Whatever that name is ("SomeTable" ), should be listed in the Available Datasets. Select that. Then, from my purpose, I change the "Name" of the dataset (the first field in the dialog) to the same value "SomeTable". This way, I am not guessing at which name is which. They will all refer to this as "SomeTable".
Now, in the report when you start adding controls, the expression dialog will show your "known" datasets (table instances) and associated fields to go.

Multiple row input in asp.net for editing database table

From time to time, I need to create an input control which allows multiple rows of input, the type of input and number of columns could be different in each case but typically it would be represent a database table being edited, so it should also be possible to store an id value within each row. It should also be possible for the user to add new rows to the input if they have more data to input.
I have tried a couple of approaches to this but they are all very long winded for what seems like such an obvious and common scenario. I'm thinking that there must be a simple way to do this that I have missed.
The way that I usually solve this is by using a list view, enter all of the input controls required within the item template and use a html table for formatting, with each item being a row of the table. If there is existing data to be edited, I would load the data from the database, add a blank object to the results and bind it to the list view. If there is no existing data, I would create a collection with a blank record in it and bind it to the list view. I add a button for adding a new row. When clicked, this button retrieves all of the existing data from the list view by iterating all of the listview items and populating the data into a collection, which I would then add a blank object to and rebind the listview with the results. When saving, I would retrieve the results by iterating the listview items again and using a hidden field within each row to store the record id. This would determine whether a new record was added or an existing record was edited.
This approach works for me but I'm sure there must be simpler ways to achieve this. Looking forward to seeing how other people solve this.
For web forms, use a GridView. You can set its properties to allow editing, deleting, new rows, sorting, and paging.
Check out the MSDN example here that shows how to use it. If you bind a datasource to it, it will figure out the columns and adjust dynamically then, or you can predefine the columns you want for more customability.
You are talking about bulk insert/update. You could use XML insertion/updation for this purpose. Get all the data to a DataSet ds variable. Then use ds.GetXml() method to convert the dataset to XML string. Pass this to an XML parameter into SQL server which has the datatype 'XML'
INSERT INTO YOURTABLE
SELECT
V.VOI.value('(.)[1]', 'int')
FROM
#Input.nodes('/DATASETNAME/DATATABLENAME/') V(VOI)
Use this link to learn more
You need dynamic table with Add, View,Edit and delete operations on each data.
I would suggest using DataTable Jquery component. there are tons of examples on Data operations, and you can plug this with any Server technology including ASP.net
http://editor.datatables.net/

Inserting the elements in grid column wise and creating different controls

I am new to Asp.net and C#.I am working in a project where I need to create GridView.Now I wanted to bind this column wise with the data.Like the column1 in the grid is "Category" in the table of database and so on. I also want to create the Hyperlink on the basis of the content in database for example I want to show the text of Hyperlink as "This is Java program" and URL specifies as "http://blogs.article?id=1".Please tell me that how I can do that.Currently I am able to bind the all three columns in the table to the three columns in the grid.
Take a look at the HyperLinkField class. This should provide exactly what you're looking for.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.hyperlinkfield.aspx

Categories

Resources