I'm using Excel's data validation lists, checking if the cell value is into a dynamic range (the cell values of another column).
The problem is that if I add a value into the source range (eg. "A"), I can input that value on the cell with data validation. But then, if I change the source (eg from "A" to "B") the cell with data validation is still "A".
In Excel there's a button that sets a red circle around invalid data, but client does not always check if everything is good.
Can I perform that check with EPPLUS?
The documentation doesn't suggest that this check can be performed by EPPlus:
https://www.epplussoftware.com/Developers/Features mentions "Create, read, modify, delete Data validations" and links to sample code in their wiki, which is all about designing the sheet and inspecting its design, no content validation.
I've searched the source code and looked at ExcelDataValidation.cs and its various sub-types. Their "Validate" methods only check if the validation is properly defined according to Excel's rules.
To achieve what you're asking for, you'll have to use EPPlus to get the validation from the cell, interpret it depending on its type and evaluate the cell content. There is an example that touches some of the cases and could give you an idea where this is heading.
Related
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'm trying to fill a table using the selenium drivers and all the documentations I could find only shows how to retrieve data from the cells. I'm able to access my table cells using:
var rows = Driver.FindElement(By.Id("Products")).FindElements(By.XPath("id('Products')/tbody/tr"));
var cells = tableRows[1].FindElements(By.XPath("td"));
But I couldn't find any way to update the data that's in it. The "Text" property only has a Get method and the SendKeys() function doesn't work. How can I edit the cell's value?
As a side note, my cell contains an html "input", I've tried to access it with the FindElement function of the cell but for some reasons it cannot find it.
Generally speaking, SendKeys should work if the cell indeed contains the input element. But because you're also saying that you fail to find the input element, I suspect that the input element does not exist in each cell all the time. You should probably first click on the cell in order for the input element to appear on that cell. You should be able to verify it using the Dev Tools if you inspect the element before clicking it.
IWebElement doesn't provide a method to change text, but you could use a little bit of JS - something little like :
((IJavaScriptExecutor)Driver).ExecuteScript("document.getElementByXXXXX.innerHTML = "VALUE";");
https://seleniumhq.github.io/selenium/docs/api/dotnet/html/M_OpenQA_Selenium_IJavaScriptExecutor_ExecuteScript.htm
I am exporting a smartsheet, and in order to maintain the hierarchy of rows, I need to use Excel format (can't use CSV). I'm wondering if IExcelDataReader will support this hierarchy of a row being contained inside of another row. I am not finding any documentation on this.
I don't see anything in IExcelDataReader that mentions Excel Row Groups. But there is an easier way that won't require you to use Excel sheets at all.
In Smartsheet, you could add another column, and add the formula =COUNT(ANCESTORS()) to each row. This will give you a numerical value you can work with in CSV format. Topmost rows will have a value of 0, children of topmost rows will have 1, and so on. In the logic that manipulates your CSV, you can then determine the hierarchy quite easily.
I want to read excel display value, not value that excel internally saves. Problem is that when this value is wider that the cell it makes cell to display ####### which is OK in excel. But I want to read this value from excel API. When I access property range. Text I also get value ########. Is there a way to get value which will be displayed when cell is wide enough?
i.e some third property, not Value2 nor Text.
My colleague said that there are three values in excel, one internal value how excel represents cell value, one what is currently displayed and one what will be displayed when there is enough space, is he right?
If this is not possible, I have another solution which might work. I used AutoFit() method to make cell wide enough and that I read value. But the problem is that I don't want to change width of columns. Is there a way to remember width, then change width so I can read cell, and that return it again to previous width?
Or maybe I should somehow apply formatting option to value of cell to get what will be displayed?
How to solve this?
In VBA I would do this by getting the Value and the number Format, and then useing the VBA Format Function to format it, but I am not sure how to do this using c#.
As a matter of curiosity, why would you want to get the formatted value anyway?
m trying to break one large Excel spreadsheet into several. I've made good progress, but I'm running into some problems. Specifically, the values that get copied over don't retain their format (for instance, 40322 instead of 5/24/2010 and -101 instead of (101.00) ). I've tried using the style (see below) but that doesn't even get me the font, let alone the number format. Any help or a poke in the right direction would be appreciated.
There are 2 loops, one for row, one for column.
destinationSheet.Cells[i, j].Style = sourceSheet.Cells[i, j].Style;
Instead of looping for each cell, you can copy/paste the entire range of cells using the pastespecial method.
http://msdn.microsoft.com/en-us/library/microsoft.office.tools.excel.namedrange.pastespecial(VS.80).aspx