KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Programmatically inserting formulas in 4D View spreadsheets
PRODUCT: 4D View | VERSION: 2004 | PLATFORM: Mac & Win
Published On: March 7, 2007
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

In huge 4D View spreadsheets the user may want to insert formulas that reference a lot of cells for calculations. The resulting formula could by quite large. As an example a calculation which references 100 cells could contain about 400 characters.

Instead of having the user insert such lengthy formulas manually, the developer can do it programmatically through use of the 4D View command PV SET CELL FORMULA. However this command only accepts parameters of type String and is therefore limited to formulas of 255 characters in length.

Another solution is to use the 4D View command PV SET CELL TEXT VALUE in your code. This command is normally used to insert text data into cells. This command accepts a parameter of type Text so up to 32,000 characters may be used. If the text starts like a formula, with a "="-sign, 4D View interprets the whole text as a formula and calculates correctly.

Documentation for PV SET CELL FORMULA:
https://www.4d.com/docs/CMU/CMU15917.HTM

Documentation for PV SET CELL TEXT VALUE:
https://www.4d.com/docs/CMU/CMU15999.HTM