Retrieve Format of a NotesViewColumn - xpages

Is there a way to find out which format applies to a NotesViewColumn? I can see that there are a number of format attributes e.g. DateFmt, TimeDateFmt, NumberFormat etc, but what I can't see is a way to identify which one of them applies.

Combine your current column's value type with NotesViewColumn's format attributes.
If your current column value is of type number then use
NotesViewColumn's NumberFormat, NumberAttrib, NumberDigits format.
If your current column value is of type NotesDateTime then use
NotesViewColumn's DateFmt, TimeDateFmt, TimeFmt, TimeZoneFmt format.

Assuming you are able to read NSF design, you could rely on DXL export to get the information needed. Try the DXL utility on Tools - DXL Utilities - Viewer:
As you may find, the piece of information you need is nested inside every <column> node.
For number columns there is a <numberformat> node.
For time columns there is a <datetimeformat> node above <numberformat>.
For text columns there is nothing.
In case you need to programaticaly analyse a number of views, there is the NotesDXLExporter on hand.

Related

Custom format with custom Multiples Excel

I recently wanted to create an excel table to note all my electric components that I have so I can easily find the right component without searching every time for it.
The problem is, especially with capacitors, they come with a wide range of values generally for me between 220uF and 10pF, and I want to create a custom format to display the values properly in excel, for example if I put in a cell 0.00022 it shows 220uF or maybe 0.22mF (but 220uF is better) and not 2.2E-04 or any other format.
I tried the custom tool but I don't know how to add the micros, nanos and picos.
You can add conditions to the formatting, like:
[<0.00001] 0.00%%% "pF";[<0.001] 0.00% "uF";#
This will show 2.20%% uF in the cell (so you can multiply by using the percent sign, more details here).
Drawback: the percent signs are shown, and the Ctrl+J trick described on the link does not really work for me (and I personally find it as an ugly solution).
If I were you I'd add a new column called "Formatted" where I multiply the values with formulas. Like
=IF(A1<0.00001,A1*1000000 & "pF",IF(A1<0.001,A1*10000 & "uF"))
It's easier then to search in both columns (one is by formatted, like all "uF", other is by real Farad value. Also you could use the original column for sorting.

How to extract numeric value instead of text from GuiTableControl?

I use Excel VBA to automate tasks in SAP.
Many times when dealing with GuiTableControl​ the numbers and dates are formatted as text, not values. That causes problems when users have different settings (commas and points as decimal separator, for example).
Is there a function like getcellvalue in GuiGridView?
A workaround would be to access the User Profile in System/User Profile/Own Data/Defaults to get the default format for the current user, and create a function to convert the text to a value depending on the default format.
Try declaring a variable and using the "text" property of the field from the script. For example:
myVariable = session.findById("wnd[0]/usr/tabs_blah_blah").Text
Then use the variable in Excel to populate the formulae to convert in the correct way.

Using POI to find out format for a cell

What is the correct way to get the CellFormatType for a cell (DATE, NUMBER, TEXT, GENERAL) ?
cell.getCellStyle.getDataFormat() returns a Short value, which does not map to the above constants.
I cannot just use cell.getCellType for the following reason. For certain rows, there may be a string prefix like <> or > in front of the value. In that case, getCellType will return CELL_TYPE_STRING. So the only way to get the underlying type appears to be to look at the format for the column.
Thanks
I don't know a direct route from Cell to CellFormatType, but there are various ways to determine particular types:
General? getDataFormat will be 0 (or more reliably, getDataFormatString will be "General")
Date? Check out DateUtil.isCellDateFormatted
Text? Typically you'd check for Cell.getCellType = CELL_TYPE_STRING, but since you say you can't do this (see comments below), you could also try checking if getDataFormatString is "#" or "text" (both are possibilities for plain text)
Number? Again, usually you'd just check for CELL_TYPE_NUMERIC. Note that dates are also considered numbers, so check for dates first.
(If the cell type is CELL_TYPE_FORMULA you should check getCachedFormulaResultType instead)
I cannot just use cell.getCellType for the following reason. For certain rows, there may be a string prefix like <> or > in front of the value
I'm not familiar with this problem. Perhaps you have a custom format which prepends characters before the number? My notes on text detection above might help you in this case, but I suggest you double-check that your spreadsheet actually has the relevant information (i.e. it isn't just Excel being clever when you re-open the sheet): log the cell type, format and format string, and confirm that there actually is a difference on the relevant cells. It's possible that your cell is actually being saved as text, with no distinguishing mark. In this case, you'll need to add some special heuristics for your specific scenario.
Finally, since you seem confused about the returned value from CellStyle.getDataFormat; it's just an index in a sheet-wide index → format-string table. You can (and I'd say usually should) use getDataFormatString to get the string format directly. The standard cell formats are listed in BuiltinFormats, which you can use as a reference to see which format strings you might find (but always check the format string, not the ID, otherwise you'll fail to detect custom formats correctly).

How to handle raw data where a column may contain more than 1 entry per row?

I have some data I would like to export (happens to be from Ruby, but that's unimportant) into a generic format for further analysis. Unfortunately, some records/lines/data entries may contain greater than 1 value (or 0, for that matter) for a given column.
For example, a person may be wearing sunglasses AND a hat. There are multiple columns like this.
I'm not sure how to handle collections of data that ideally could fall under the same column in a generic format (I need to import this data into other software, ideally including Excel).
The only simple, generic method I can think of is to have a column for each potential piece of data and treat it as a boolean. But I'd rather not, since then I would end up with over 300 columns. And then I'd also have to include a secondary CSV file that specified which columns belong to which categories.
If you want to output that data to a csv file, you could group the data into one field using a different separator:
John,sunglasses|hat,other,fields
Or using the same separator, but then the field needs to be quoted (and quotes already inside the field would need to be escaped with another quote):
John,"sunglasses,hat",other,fields
Or, if the number of other fields is not large, you could use a row for each value:
John,sunglasses
John,hat
Or you could use xml:
<record>
<name>John</name>
<options>
<option>sunglasses</option>
<option>hat</option>
</options>
</record>
It all depends on how you want to process the exported data.

Cognos frame work manager: format numeric column to show currency dynamically

In this url, it is shown how you can format a particular column to according to particular currency.
http://publib.boulder.ibm.com/infocenter/caapps/v10r1m0/index.jsp?topic=%2Fcom.ibm.swg.im.cognos.ug_fm.10.1.0.doc%2Fug_fm_id13919format_SAP_query_items.html
Now in a result set, there may be 2 rows and each may be of a different currency and also different number of decimals. According to the method here, it seems that we need to hard code the currency and the number of decimals on the entire column. Is there a way to set it dynamically?
I have two columns in the result set, one is the amount the other one is the currency. Based on currency, i want to format the amount column. From db, the amount column just comes back as a number.
How can I do it?
I can't think how this would be done in Framework Manager. You can do it in Report Studio however.
He are some high level instructions on how to do it in Report Studio:
In Condition Explorer, create a variable which results in a different string for each currency. For example if your currency code field is [Table].[CurrencyCode] and it has things like 'AUD','CAD' etc. in it then your variable expression would just be the field:
[Table].[CurrencyCode]
This will simply output the currency as its result
Still in the variable creation screen, add values the the 'Value' window to for each possible currency code result
Go to the report page, click on the field that contains your actual currency value (i.e. 13.50 and set it's Style Variable property to the variable that you just created
Now go back to condition explorer and select your first currency
Ensure your currency value field is selected and edit the 'Data Format' field to the appropriate format
Repeat 4 & 5 for each currency
Here is another guide to how to do this:
http://www-01.ibm.com/support/docview.wss?uid=swg21339405
This is called 'Conditional Formatting' if you would like to research it further.
Unfortunately this solution needs to be done at the report level and can't be done down at the the FM level. I'm not aware of a way that you can conditionally set the data format in FM like this.

Resources