Aspose Cells Numeric Formatting With Processed Datasource - excel

I am new to Aspose Cells, having inherited a project that uses it. A requirement was added that numeric values in cells be actual numbers - they were formerly text.
So, I changed calls in the code that called Cell.PutValue() to use the overloaded version of the method that takes the bool isConverted. Passing a value of "true" in that parameter solved the problem for these instances.
However, in other places in the code, we export data from our website into a spreadsheet by using ExcelDesigner.SetDataSource() and ExcelDesigner.Process(). The spreadsheets resulting from this approach also have numbers stored in cells as text.
How can I convert the text to numbers in this case, as I did with the PutValue() case?

It turns out that Aspose uses something called "Smart Markers", which are directives embedded into the cells of template spreadsheets that Aspose Cells uses to decide how data should be inserted into them.
Smart Markers have optional "parameters", which are parenthesized, comma-separated modifiers giving further processing instructions. The "(numeric)" directive achieved the result that I was looking for.

You may also post a query directly in Aspose.Cells forums, in case you need any further assistance. As those forums are monitored by our support and development teams.
Disclosure: I work as developer evangelist at Aspose.

Related

Why does carriage return in excel is not reflected when excel value is imported in UFT

I am using Excel to compare error messages. My error message looks like this .
You have changed the values.
Do you want to continue?
I entered this value in excel using Alt+Enter, when reading this value from UFT, this carriage return is not considered.
How to include carriage return in excel so that it is visible when reading the values from UFT?
First, try to create a string formula, i.e. instead of entering the line break in the string, create a formular like
="<value>"
where <value> is the string value that you originally wanted in your cell, with the line feed contained within the quotation marks.
This might solve your issue.
But:
This is just the top of the mountain of known issues with UFTs data table API. Here is an incomplete list of additional issues (some of which, but not all, are fixed or at least improved upon in 15+):
Date values are not properly handled, especially if you are using a
non-US locale and try to consume values auto-formatted by Excel as
dates
Strange things happen if you have an .xls file. Use an .xlsx file instead. (This used to be the other way around). Note it is not only the extension I am referring to, but also the format (Excel-95 vs. more modern format)
Many formulas are unsupported Formatting behavior differentfrom what Excel would do/show
CRs and LFs are handled differently
from what Excel does
Built-in table editor is quite a silo of bugs
and antiergonomic cell values are limited in length; at the same
time, formulas have different length limits. I.e. a string in a cell is
limited to a certain maximum number of characters, but a formular
returning a string does not have that (but maybe a higher) length
limit
Because of this (and more), we auto-convert all excel sheets on the fly before when we use them in UFT after they have been updated. To do this, we are using Excel Interop (i.e. Excel´s COM automation interface) to spawn an Excel instance, create a converted version that has all formulas and formatting resolved to just string formulars, and use the converted sheets with UFTs DataTable.ImportSheet feature. Which means we unfortunately need Excel on all execution machines.
So my recommendation would be to stay away from the data table editor in UFT. Use Excel, and make sure all your edits come through to UFT in a meaningful way. If they don´t, consider a converter that creates a DataTable-compatible copy of your sheet.
Yes, I know this is suboptimal, but that´s what it has come down to after years and years of struggling with the DataTable API and UFTs "superb" built-in data table editor.

Getting the excel displayed value

I've been scouring for days and I can't seem find what should be an easy answer. The displayed value is not necessarily the value that from cell.InnerText. I see post after post that requires you to look at the cell.StyleIndex property & cell.DataType.value to determine how to get the displayed value. And while I have plugged in some of this code and it works I hit another case I didnt handle where the cell StyleIndex is null which I can only assume the cell is formatted as "General". The on screen value "-39718.96" while the cell.InnerText returns "-39718.959999999999". I realize there is a easy fix to this by Double.Parse(value).ToString() but there seems to be an endless supply of formats https://stackoverflow.com/a/4655716/1713000 and that's a shortlist and dates are another problem. It seems we are left to handle each different style ourselves. Did Microsoft really not create a public api that returns the formatted displayed value and has no one really written a complete solution to handle this cluster of a mess?
Using Openxml for sheets is very difficult (much more so than using it for Word). If I were you I'd use the ClosedXMl nuget package as it simplifies Openxml for sheets.
Will use the ClosedXML lib instead

Merge Cells in DevExpress VGridControl and Export to Excel

I want to do a simple merging of cells in a DevExpress VGridControl. The attached image shows exactly what I need. I have come across a lot of support tickets by DevExpress and all are redirected to just one link of Devexpress Sample E3019.
Firstly this is a very complex process, but even if I use this to merge cells in my VGridControl, the cells are not merged in the excel file when exported.
I had posted this question in the Devexpress Support Forum but did not get a positive reply on the same :
https://www.devexpress.com/support/center/Question/Details/T392883
(Please do not confuse the VGridControl with GridControl - they are two different functionalities used for different purposes)
The below image exactly shows what I want to achieve
I managed to get this functionality in place by first exporting the VGridControl to Excel and then reading the Excel file from C#. We can perform cell by cell operations and formatting using c# - refer the below link :
http://csharp.net-informations.com/excel/csharp-format-excel.htm

default value to a cell of a new row without a macro (Excel)

I would like to insert a default value, to a specific cell in my worksheet,
but this default value should take care of new rows inserted in the worksheet.
I must not use a macro for this.
thanks
Maybe I am wrong, but I can not think of any way, one would be able to that. This is more a typicall database functionality. Without macros you would have to use a function or a format. A function, like values, would not be copied by inserting new rows - only formats would, so this narrows it down.
By the way, I interpreted your question to "default value on instertion of new row", not "default value when writing data in a existing clear row".
So, as a kind of "default value behaviour" you could use user defined cellformats.
i.e. use ;;'x'; as a user format and format your cell or column with it. This won't fill empty cells with 'x' but, whenever you would type in '0' it would change to 'x'.
However, I am very interested, if there is a better solution.
You can add validation to cells which can help you force a number into a particular cell, but as stated in the earlier answer a database is more designed for Default Values.
It seems to me you are trying to create a database in Excel, I wouldn't recommend this as excel is very good at prototyping algorithms however when it comes to structuring tables it can fail very quickly.
Use at least MS Access, namely as it comes with a database. Alternatives are rapid prototyping tool such as Eclipse or Netbeans, or Visual Studio if your budget can stretch that far. Couple the RAD tools with MySql (namely for ease of use and the fact that the community licence is good) and the system should be stable.

What is the best way to import data from sophisticated formula enriched Excel files into SalesForce.com?

My current employer (to remain nameless) has a collection of incredibly sophisticated Microsoft Excel 2003 worksheets (developed by contractors, also to remain nameless).
The employer is replacing the Excel-based solution with a SalesForce-based solution (developed by other contractors, likewise to remain unnamed). The SalesForce solution is also very complex using dozens of related objects and "Dynamic SOQL" to contain the data and formulas which previously was contained in the Excel-based solution.
The employer's problem, which has become my problem, is that the data from the Excel spreadsheets needs to be meticulously and tediously recreated in .CSV files so it can be imported into SalesForce.
While I've recently learned I can use CTRL-` to review formulas in Excel, this doesn't solve the problem that variables in Excel have cryptic names like $O$15. If I'm lucky, when I investigate $O$15, I'll find some metadata explaining if n cells up and/or some other data m cells to the left, and/or (in rare instances) there may be a comment on the cell.
Patterns within the Excel spreadsheets are very limited, rarely lasting more than 6 concurrent rows or columns and no two sheets which need to be imported have much similarity.
Documentation of all systems are very limited.
Without my revealing any confidential data, does anyone have any good ideas how I might optimize my workflow?
It's not clear exactly what you need to do: here are 3 possible scenarios, requiring increasing knowledge of Excel.
1. If all you want is to convert the Excel spreadsheets into CSV format then just save the worksheets as CSVs.
2. If you just want the data and not the formulae then it would be simple (using VBA) to output anything that isn't a formula (the cell.Formula won't start with =).
3. If you need to create a linkage excel-->csv-->existing Salesforce objects/SOQL then you will need to understand both the Excel Spreadsheets and the Salesforce objects/SOQL that have been created. This will be difficult unless you have good knowledge and experience of Excel and also understand what the salesforce App requires.
Brian, if you're still working on this, here's one way to approach the problem. I use this kind of process often for updating data between SFDC and marketing automation apps.
1) Analyze the formulae that you're re-creating in Salesforce.com to determine what base data fields you need (stuff that doesn't have to be calculated from something else.
2) Find those columns/rows in your spreadsheets and use Paste Special -> Values in a new spreadsheet to create an upload file with values instead of formulae that you need for each data area (leads, prospects, accounts, etc.)
3) If you have to associate the info with leads or contacts or accounts and you have already uploaded or created those records in Salesforce.com, be sure to export them with their ID numbers. That makes it easy to use the vlookup formula in Excel to match up fields that you need to add and then re-upload the data into Salesforce.
Like data cleaning, this can be a tedious process. But if you take it step by step it shouldn't be too hard. Good luck.

Resources