How to do single select in excel - excel

Im using write_xlsx gem and having multiple select in excel(written in vba) and now i want single select in only one cell.
Is it possible to do with data_validation? or i have to modify with vba?
worksheet.data_validation('D2',
{
:validate => 'list',
:value => ['One', 'Two', 'Three']
})
Thanks

Related

Backpack for Laravel - Column with formatted text

I am wondering how to add a column with formatted text. I need to add tag to make multi line column in show Operation.
I found it:
$this->crud->addColumn(['name' => 'myName', 'label' => 'myLabel', 'type' => 'text', 'escaped' => false]);
So add index 'escaped' with value false.

How to allow empty or a string validated by a regex in JOI?

I am to pass a vat value. The validation should allow saving it in the db if it is empty or passes the given regex of a certain country.
.when('country_code', {
is: 'AT',
then: Joi.alternatives([
Joi.string().allow(''),
Joi.string().regex(/(AT)?U[0-9]{8}/)
])
})
This what I have achieved till now but it isn't working.
This is what you are looking for:
Joi.string().regex(/(AT)?U[0-9]{8}$/).allow('')

Format column as Zip Code when exporting from ag-grid

I am exporting to Excel using the Enterprise Ag-Grid built in solutions. Whenever I export a zipcode, any zipcode that begins with 0 loses that in the Excel file. I know that Excel supports a special Zip Code format, however, I keep striking out on my attempts.
{
headerName: 'ZIP',
type: 'zip code',
filter: 'number',
unSortIcon: true,
field: 'Zip',
filterParams: {
filterOptions: this.filterOption,
clearButton: true,
applyButton: true
},
minWidth: 120
}
That is how the column is currently defined within the columnDefs of the gridOptions.
Thank you in advance for any assistance or insight you may have.
Regards,
Youssef
You can format the required cells in your spreadsheet as "00000" which will show the required formatting. Format cells->Special->Zip Code.

Split a string into indexes in a List of Lists

I have a collection of text that I am trying to parse in order to audit against. In Python3 I am trying to split the white space in a list of lists so that each word gets its own index and then add data that is missing to some of the lists . Ex:
listoflists=[['Port UP UP Description'] , ['Port Description' ],[ 'Port UP UP Description']]
I'd like to make it so that the output of listoflists now contains:
listoflists=[['Port,UP,UP,Description'] , ['Port, Down, Down, Description' ],[ 'Port,UP,UP,Description']]
My goal here is to then use this data to output to prettytable or something like that with rows containing each for indexes from each list and then, phase 2, audit against which rows have 'Ports' showing down.
I tried something like this but I believe my thinking is not quite right here.
for i in range(len(listoflists)):
listoflists=i.split(' ')
for item in items:
new_items.extend(item.split())

Keep the right type while assigning value to a cell

I want to initiate a worksheet with a JavaScript object which looks like { "A1:B2": [["01", "02"], ["03", "04"]], "C5": [[4]] }, I have the following code:
function sheetIni(data) {
return Excel.run(function (ctx) {
var sheet = ctx.workbook.worksheets.getActiveWorksheet();
for (var key in data) {
if (data.hasOwnProperty(key)) {
var range = sheet.getRange(key);
range.values = newData;
};
}
return ctx.sync().then(function () {
console.log("done")
})
})
};
I realise that the result in the worksheet turns out to be respectively 1, 2, 3, 4 in A1, B1, A2, B2; it converts automatically a string to a number (eg, "02" to 2).
Does anyone know how to avoid this automatic conversion?
In general, how could I make sure a javascript value can be faithfully assigned to a cell value without extra conversion?
The safest thing to do, when assigning data to arbitrary cells, is to set number formatting first, and then the value.
For text strings, the "#" number format serves as a way of declaring "I want this cell to contain a text string, even if it comes in as a number". It's the same as the user entering values into Excel manually.
For future reference: if you want a working code snippet back, the easiest way of ensuring it is to first create and share a snippet using Script Lab and share a link to it in the question. That way, it would be very easy for someone like myself to import the code, make a quick tweak, and send you a final snippet back.
Another way is to prepend numbers that you want to be treated as text with a '
[["'01", "02"], ["'03", 4]]
will result in excel
[["01", 2], ["03", 4]]
This avoids having to format cells as Text (which can have nasty side effects)
When retrieving an array of values from Excel you can load types as well as values and then loop the array prepending text numbers with ' before sending the array back to Excel.

Resources