I have to dynamically read about 2000 files in Excel xlsx format, to import data to database using csharp. It´s not tabular data, no head columns at all, the data has to be read dynamically, because the positions of the cells change according to the product data, we have labels cells to find the data. My biggest problem is I can not read the value of combo boxes cause positions, name and quantity of cells/combos will change depending the product, but the labels will remain the same. I tried to export to every single format type but it doesn´t works, the combo selected value after specific cell label dissapears.
Any possible solution?
Ex. of my spreadsheet:
row A1: label|value|null value|label|value|merge cells label|value
row A2: label|producttypecombovalue
row A3: label|producttypecombovalue
row A4: label|producttypecombovalue...
row AX..: label|value|label|value|merge cells label|value
If the combo boxes are all positioned over the cell to the right of the label then you can filter all of the combos on the sheet by looking at their location (ie. their TopLeftCell property, or Top and Left properties) and using the one which most closely matches the expected position of the one you're looking for.
In VBA (using Forms combos, which from your screenshot are what you're dealing with) -
Sub tester()
Dim o
For Each o In ActiveSheet.OLEObjects
Debug.Print o.Name, o.Top, o.Left, o.TopLeftCell.Address(), _
TypeName(o.Object)
Next o
End Sub
Related
I first would like to say that I am fairly new to UWP, and my experience with Android is probably leading some some assumptions on my end. There may be a better way about this, but so far I have been trying to use the Grid class, but it doesn't seem to work in a way that I would expect.
Basic Idea
I am trying to create a UWP application with the ability of organizing elements in a matrix, where each row and column represents some category, and whatever element that is within both row and column categories is placed in that cell. One or more elements can be listed in each matrix coordinate. An image for reference is below:
To give a more clearer/specific example, let's say the Elements were Employees, rows were Teams, and columns were disciplines (Testing, Dev, Management)
Comparing different category-types can be useful for displaying information, but this will have greater importance beyond just names, so this is only a simplified example. Also, as shown in the example, the number of rows and columns is determined by the number of categories there are for each respectively (e.g. # rows = # teams and # columns = # disciplines).
I don't have any code to show, simply because this isn't so much an error problem as it is a conceptual problem.
My Questions
How would I be able to filter what elements are bound to a cell by their Row/Column? Is this even possible?
i.e. populating the cells of the matrix with elements that occupy both the corresponding row's and column's category.
How do I bind columns and rows to their respective list of categories?
e.g. whenever I add another Column Category, a new empty column will be generated.
I appreciate your help and time!
For your scenario, the better way is using DataGrid to replace.
i.e. populating the cells of the matrix with elements that occupy both the corresponding row's and column's category.
You could use binding way to specific current element in which column and row, but you need to calculate before preparing data source for Grid panel.
whenever I add another Column Category, a new empty column will be generated.
If you use DataGrid, it will generate Column base on your item's new filed. Here is code sample that your could refer.
I am displaying an array of doubles using a DataGridView.
(There is no limitation on the dimensions of the array)
I intentionally don't display every decimal place of each double to the user, instead I set the format of the cell to something like:
dataGridView.Columns[i].DefaultCellStyle.Format = "f3";
So, a value 1.112233 would be displayed as "1.112".
However, when copying a selected cell to the clipboard and pasting into Excel I only ever get the displayed precision. I would like to know if there is a straightforward way to specify that I want the cell Value to be copied to the clipboard not the FormattedValue?
Please note that I am not limited to copying single cells, I would like the user to be able to copy multiple cells, ie
dataGridView.MultiSelect = true;
dataGridView.SelectionMode = DataGridViewSelectionMode.CellSelect;
When debugging I have verified that the Value property on the cell does indeed contain the original double.
I have specified the the ValueType is a double.
I attempted to override the Ctrl + C command with a key down event and output the selected cells to the clipboard manually. However, the order of the cells in the dataGridView.SelectedCells does not necessarily match the order in which they were selected. For example, when two neighbouring cells are selected their order seems to have been arbitrarily reversed. ie select a value in column 0 and then a value in column 1, the order in the dataGridView.SelectedCells was column 1 and then column 0.
It feels too convoluted and excessively inefficient to have to manually sort these back into a sensible order before then manually copying to the clipboard.
Is there a simple way to do this or do I just have to put the effort into the manual copy?
I have a GridView that gets its data from a SQL Server stored procedure. There are Item Templates in the grid to allow for data entry. I have a column with a CommandButton at the end of each row.
What I'm trying to accomplish:
If the user clicks the button, a new row gets inserted which is a duplicate of the previous row. Scenario: while doing data entry, an item has more than one bin location. By duplicating the row, the end user can enter the 2nd bin location, where both records get dumped to a database.
I've been looking around and trying to filter out the remove duplicates from my research. Can this be done without putting the GridView into a datatable and rebinding? Is there a simpler way to do it server side? Does it need to be added in the footer?
Unfortunately, you can't use the same row or same cells because the DataGridView only takes unique rows and cells. You'll have to get the values of that row and use them in a new row. I wrote a little bit of code to do this
string[] cells = (from c in datagridview.Rows[e.RowIndex].Cells.Cast<DataGridViewCell>()
select c.Value.ToString()).ToArray();
DataGridViewRow row = new DataGridViewRow();
row.CreateCells(datagridview, cells);
datagridview.Rows.Add(row);
I hope I understood your question right. This is just something to get you started. I'm pretty sure it will not resolve your problem completely, but it's something.
I want to read and display an excel file in a web page. I am using Microsoft.Office.Interop.Excel in .aspx.cs and GridView in .aspx. I am just reading it into a DataTable and binding it to GridView.
The problem with this is, I can't handle merged cells. For example, if two columns are merged in Excel, while displaying, it will show two columns with the value in first cell and second cell will be empty. I just want to retrieve the sheet as it is. Is there any way to achieve this?
Microsoft.Office.Interop.Excel is designed to provide programmatic access to excel files. It will do some formatting work (see Text property) but most of the difficulty of rendering is left to the consumer (your program).
MergeCells will return True if you have a merged cell and MergeArea will return a Range containing the merged cells. You can then use the RowSpan and ColumnSpan fields of the GridView's cells to duplicate the functionality.
I have UltraGrid and i need when i click on grid row to get content from specific column of that grid. For example if I click in cell of fourth column then i need to get value of first column of the same row where i clicked.
Thanks!
I am not familiar with UltraGrid, but from what I just read at:
http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.Aspx?ArticleID=1753
I believe you can simply get your value like I would from a VB.NET datagridview.
dim obj as object = UltraGrid1.Selected.Rows(0)..Cells.FromKey("Name of Cell").value
This should be a close proximity of what you need.