How to Read a Specific Column of Excel and Update Related Values - c#

Can you please let me know how I can use C# to read a specific column values base on the column header?
For example, let say I have a column with header "pAge" how I can loop into the column and update values for the specific rows related to the garbed values. What I want to do is looping in "pAge" column and find all ages over 50 then change the value of those rows in other column "Eligible" to "yes"
The reason that i would like to use the column header instead of column range is because I am getting some data from our clients which are not necessarily in the same order but they have always same name.
Thanks for your time

try using this linq to ecxel library it should help you achieve what you are looking for
http://code.google.com/p/linqtoexcel/

Related

Splitting csv strings and display it in different fields?

So basically I'm designing a report which can record name and amount of individuals. Now, I have no idea how to implement this on my cr report. But I need to split the csv strings and put all the splitted value as columns.
Here is my sample cell
I have 2 sample columns, Name and amounts. Both columns represent individual cell. Name is a single cell seperated by newline and same as amount.
In my desired output, I need to split all the values inside cell "Name" and put it in different column in Crystal Report and i also need to display the values of "Amount" Below the "Name". Which splitting is needed
Can this be theoretically be done? Any help is appreciated!
Thank You!
Yes, simply use the menu option of Insert, CrossTab... to insert a crosstab in the report header or footer.
Select Name as the column field.
Select Amount as the field to summarize.

DataTable columns inside columns or merged row table structure

I've had a Google but I find no answer. You know how say in MS Word, when you insert a table, you can merge the columns of one single row to create a column-less row? Or have say a main header and then more columns inside it? Like so:
Merged Row:
|Column 1|Column 2|Column 3|
|Value|Value|Value|
|Merged Row|
|Value|Value|Value|
God the text formatting is awful on this web-site...and the Header Column example:
|Main Header||Another Main Header|
|Column 1|Column2||Column1|Column2|
I'm trying to achieve this in a written DataTable in C# which is being populated by an array. But I'm interested in changing its structure as one of the above, whichever is possible/easier.
So I've created my DataTable and added normal columns and rows etc. But I'd like to create either a merged row or a main header to display. Instead of having a repeated value in a single column for the values I am getting.
Can someone please provide a quick example on how I could achieve either one of those? Because repeated value will just look ugly.
Cheers.
You're talking about displaying data in a particular way but a
DataTable has nothing to do with display. It is for storage and that's
that. How you display the data is up to you. The same data can be
displayed in innumerable different ways. In a WinForms app, one of the
most common ways to display the contents of a DataTable is with a
DataGridView. You can choose which columns to display and merge cells
in that grid if desired. In short, you're looking in the wrong place
to do what you want to do. It is a presentation issue, not a data
issue. –
jmcilhinney

Change Group By column order in ReportViewer

I have a rdlc where I'm building a report.
I'm using a tablix grouping by a field of the tablix dataset, like the following:
When I fill the report with data and refresh it, it comes out like this:
Now, I want the first column(wich has the group by by the field "nome_terr") appear not in first place, but by second. The first column has to be "territorio_emp". If it was a normal column, I'd just move it, but being the Group By column I don't know how to do this.
Ideas?
Thank you.
If you know that your Territorio_Emp data is 1-1 related to your Nome_Terr column, you can just group by Territorio_Emp first, then by the Nome_Terr column.
If thats not possible, you can keep it the way it is, but make the width of the group by column 0, so its basically hidden. Just drag the column header separators.

Telerik Radgrid Can we save a unique value against each column?

I am generating columns dynamically in my RadGrid, so column count and their names are generated on the fly and so is the datatable that the grid is to be bound to.
Each column either represents an object in my system, or an empty one for user to create a new object. Each object is identified by a unique value property.
I would like to set this value to the column, so, when the grid is edited, I would like to use this value and update the object.
I am open for suggestions. For now I am thinking the options are
assigning the value to a property in GridTemplateColumn(which I dont think is possible)
use a hidden field in header of the column (how do I do it?)
To be more clear, both rows and columns are generated dynamically. I am using DataKeyNames for rows. Wondering how I should be storing unique values for columns!
Any help is appreciated.
Thanks!
I doubt if an official Telerik support exists here for this situation. One quirky solution will be to employ a row of hidden fields, one field per column, each storing unique value for the column.
You can add the unique value to one of the columns in the datatable and bind this column to grid. Make this column invisible so that it is not visible in the UI, but accessible in the backend.

Cleanest way to implement collapsable entries in a table generated via asp:Repeater?

Before anyone suggests scrapping the table tags altogether, I'm just modifying this part of a very large system, so it really wouldn't be wise for me to revise the table structure (the app is filled with similar tables).
This is a webapp in C# .NET - data comes in from a webservice and is displayed onscreen in a table. The table's rows are generated with asp:Repeaters, so that the rows alternate colers nicely. The table previously held one item of data per row. Now, essentially, the table has sub-headers... The first row is the date, the second row shows a line of data, and all the next rows are data rows until data of a new date comes in, in which case there will be another sub-header row.
At first I thought I could cheat a little and do this pretty easily to keep the current repeater structure- I just need to feed some cells the empty string so that no data appears in them. Now, however, we're considering one of those +/- collapsers next to each date, so that they can collapse all the data. My mind immediately went to hiding rows when a button is pressed... but I don't know how to hide rows from the code behind unless the row has a unique id, and I'm not sure if you can do that with repeaters.
I hope I've expressed the problem well. I'm sure I'll find a way TBH but I just saw this site on slashdot and thought I'd give it a whirl :)
When you build the row in the databinding event, you can add in a unique identifier using say the id of the data field or something else that you use to make it unique.
Then you could use a client side method to expand collapse if you want to fill it with data in the beginning, toggling the style.display setting in Javascript for the table row element.
just wrap the contents of the item template in an asp:Panel, then you have you have a unique id. Then throw in some jquery for some spice ;)
edit: just noticed that you are using a table. put the id on the row. then toggle it.

Categories

Resources