How is it possible to display a formula in Libreoffice by a simple change of the formatting or the cell settings of the desired cells?
I'd like to have a table which displays the results and another which displays the formulas next to each other. (at the same time)
The solution Options->LibreofficeCalc->View->Formula doesn't work as the whole document is affected. Also in the print-preview it falls back to the results. (I wish to print it later)
The plugin Display Formula and Result (Value) simultaneously does display them both at the same time but I'm not happy as it seems to work under limited conditions only (Some working formulas are just displayed as ### and if I use it on the whole table it formats cell by cell without the ability to undo it. Having a 5x5 table will cause 25 Ctrl+Z if it's not working as supposed)
use the formula =FORMULA(cell) to display the formula used in cell
If you specifically require formatting, then the Display Formula and Result (Value) simultaneously add-on seems to work as desired.
Formulas are displayed as ### if the cells are too small. When this occurs, resize the columns and the full formula will appear.
As to undoing quickly, there are a number of methods:
Select the cell range and go to Format -> Clear Direct Formatting.
A table of 5x5 can be quickly undone by holding down Ctrl+z for about two seconds.
Format -> Conditional Formatting, and hold down shift to select multiple. Press Remove.
Format -> Styles and Formatting, and hold down shift to select multiple styles. Then delete them.
Reset the whole sheet by running the CFClear macro from https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=62169.
Save the file first and then reload if it is not what you wanted.
To me, the biggest downside of the add-on is that it can potentially double the file size, and it clutters up conditional formatting and cell styles. But if formatting some cells as a formula is a priority, then it seems like a good solution.
Related
I am fairly new to using PeopleSoft BI Publisher plugin for MS Word and integrating it with PS Query Manager. My question is whether in the RTF file you can put logic to suppress or filter out data?
I have a for-each grouping that prints a line (row). I would like to add logic to NOT print the line if the Witholding amount field (M.WTHD_AMT) is equal to 0 (zero). My question is what would the syntax look like, and where should I place it (on the For Each grouping below, the Field level, or somewhere else?) I know I can alter the PS Query (data source) to do the filtering but I would like to leave that as-is and handle this in the template.
I see that there is another conditional IF statement ("rmt_") so I'm not sure if I can add this additional logic to that element or if I need a separate one. I appreciate any feedback!
EDIT:
I've added a new "Conditional Region" as suggested, and it works with just the WTHD_AMT criteria !0 to zero, however I tried added additional criteria where L.PYMNT_TYPE = 'R' and when I run the process it doesn't display data on the PDF output. Is there something wrong with the syntax? Do I need to have a separate Conditional Region for this 2nd criteria? I've seen another BI report where they have 2 or 3 criteria as part of one element.
<?if:number(M.WTHD_AMT)!=0.00?> and <?if:L.PYMNT_TYPE='R'?>
Option 1
You can nest <?if?> statements. Just add another <?end if?> at the end. Make sure there are no spaces between the all of the IF or END IF objects at the beginning or end of the content/row, else the row may still be displayed.
Option 2
You can add conditions in the repeating section. Below will repeat the region for every record where M.WTHD_AMT is not 0.00
<?for-each:record_path/record[M.WTHD_AMT!='0.00']?>
'Conditional Region' is the button you are looking for.
When using this button, make sure to double check where the if/endif or C/EC elements are added. It tends to ignore the selected element and join the elements to the start and end of the line. You will then need to cut and paste it into the right spot. For you this will probably be right after the F element and before the E element.
I am faced with rewriting an Excel project in R. I see a table in which a cell {= TABLE (F2, C2)} is shown. I understand how to create a Table like this (What-If Analysis, Data Table...).
As I have to understand this to rewrite in R, how can I find the original formula which stands behind that cell?
EXAMPLE: I have created a Data Table as shown here and the sheet looks like this:
In my case, I don't know how the sheet was created, and I want to know the initial formula. Now this is shown as {=TABLE(,C4)}.
(In the example I know the answer, it is in the cell (D10), but where is reference for this cell in Data Table?)
I'm using Excel 2007 but have no reason to believe things differ in other versions.
#Stanislav was right to reject my comment suggestion that TABLE was a name; it is an EXCEL function. But it is a very strange function :-}
There isn't any help on the TABLE function in the local help, it isn't listed in "List of worksheet functions (alphabetical)".
You can't manually enter or edit the TABLE function; error "That function is not valid".
Copy/Pasting cells containing the TABLE function pastes their values, not their formulae, even when you specify Paste Special > Formulas
You can't insert rows/columns immediately above/left of cells containing the TABLE function; error "Cannot change part of a data table".
Pace #pnuts using Formulas > Formula Auditing cells containing the TABLE function shows no precedents and no cells show them as dependents. Although in a VBA sheet auditing tool which I use the Range.DirectDependents Property finds the "formula range" dependent on the "margin" cells containing the formulas, but not those containg the values (see below for explanation of those terms).
I haven't been able to find anything I regard as decent documentation of TABLE(). I have found lots of illustrations of how to produce and use that function, but nothing clearly specifying the arguments and result. The best I've found is https://support.office.com/en-us/article/Calculate-multiple-results-by-using-a-data-table-e95e2487-6ca6-4413-ad12-77542a5ea50b. I'd be pleased if anyone can point me to better documentation.
I deduce the bahaviour as described here:
TABLE(Rowinp,Colinp) is an array formula in a contiguous array of cells. I'll refer to that contiguous array as the "formula range" of the data table.
The cells immediately above/left of the formula range are also part of the data table, even though they do not contain a TABLE() function and can be edited; I'll refer to those cells as the "margins" of the data table.
Rowinp and Colinp must be blank or references to single cells.
Rowinp and Colinp must be different (or error "Input cell reference is not valid"), they must not both be blank.
The values in the formula range are calculated by taking formula(s) from the margin(s) and substituting references to Rowinp and/or Colinp with values from the margin(s).
There are three mutually exclusive possibilities, corresponding to Rowinp blank or not.
TABLE(Rowinp, ) Colinp blank. The formula is that in the left margin of the same row with instances of Rowinp replaced by values from the upper margin of the same column.
TABLE( , Colinp) Rowinp blank. The formula is that in the top margin of the same column with instances of Colinp replaced by values from the the left margin of the same row.
TABLE(Rowinp, Colinp) Neither blank. The formula is that in the cell at the intersection of the left and top margins with instances of Rowinp replaced by values from the upper margin of the same column and instances of Colinp replaced by values from the the left margin of the same row.
I think that should let you work out what the effective formula is in each cell of the formula range.
But I wouldn't be surprised to learn that any of the above is wrong :-0
I welcome pointers to anything more authoritative.
I think in your example the F2 and C2 are effectively only the addresses of parameters for a function (TABLE) where that may be located anywhere, with the associated formula in the table's top left cell.
So I suggest go to C2, FORMULAS > Formula Auditing and click Trace Dependents, repeat for F2 and see where the arrows converge.
It is possible to use getValue(), getCalculatedValue() and getOldCalculatedValue() to retrieve the value of a cell in phpexcel.
Is there a way to determine programatically the content type of the cell and apply the corresponding correct method. I need to use this in a general way. i.e. to display the same value as when opening excel.
I know there is something called getDataType() but not sure how to apply it in this case (not in documentation). In my experience sometimes only one of these three retrieves the correct value.
(i.e. sometimes getOldCalculatedValue works but not getCalculatedValue for a formula for example. other times only getvalue works, etc.)
getOldCalculatedValue() is used to retrieve the result of a previous calculation in MS Excel itself; and should not be relied on, because it is possible to disable autocalculate in MS Excel, which can leave this field empty, or even with an incorrect value. It is used within PHPExcel as a "fallback" for cell formulae that are reliant on external spreadsheet data, but it still shouldn't be trusted as an absolute.
getValue() returns the "raw" value of the cell. The returned value may require "interpretation". A cell containing a date and/or time is simply a float value in MS Excel, so it will return that float (e.g. 42017.7916666667 instead of a human-readable date/time like 13-Jan-2015 19:00;
and it will return the actual formula if a cell contains a formula (e.g. =TODAY()); or 0.8 for a value that might be formatted as a percentage and that appears as 80% in MS Excel itself.
getCalculatedValue() will attempt to execute a formula calculation if a cell contains a formula, and return the result of that calculation. If the cell doesn't contain a formula, then it will return the "raw" value, in the same way as getValue(). While PHPExcel has a fairly good calculation engine, it isn't perfect (it can't handle 3d cell ranges or array formulae for example), so it is possible for some formulae to fail. Likewise, formulae containing references to external resources may also fail, and while PHPExcel will attempt to use the getOldCalculatedValue() in that circumstance, it isn't (as mentioned above) guaranteed to maintain the correct result.
getFormattedValue() will execute getCalculatedValue(), and then apply any number formatting mask that applies to that cell against the result, so that (for example) a float with a date mask will be displayed as a date.
However, if you've loaded a spreadsheet file with readDataOnly(true), then that tells PHPExcel not to load any formatting, including number format masks, so it will not be able to format the result.
When you access MS Excel itself, then the closest result to the values displayed in MS Excel itself will be getFormattedValue()
If I save a phpexcel document in Excel5 format that contains values only, people that reference the document can open and close it without issue.
But if I put some formulas in cells, I have two undesired outcomes.
Just before saving the document I set the column widths based on the contents of the columns. Since the formulas have not been calcuated, the columns appear to be only as large as the largest single value in the column so the width is set too narrow. Once the =sum() formulas are calculated after being opened in excel, the contents overflow the cell width and display as a string of ###.
The second effect is that when the total is calculated by excel, the book is marked as modified by excel. When the user attempts to exit the book, they are prompted to see if they want to save their changes. This is disconcerting because in their mind they have not changed anything and annoying because it is an interuption that they really don't want to contend with.
I have been searching the documentation. I found a reference to $objWriter->setPreCalculateFormulas(true) but it does not help with either issue.
If a column is set to AutoSize, PHPExcel attempts to calculate the column width based on the calculated value of the column (so on the result of your SUM() formula), and any additional characters added by format masks such as thousand separators. By default, this is an estimated width: a more accurate calculation method is available, based on using GD, but this is a much bigger overhead, so it is turned off by default. You can enable the more accurate calculation using
PHPExcel_Shared_Font::setAutoSizeMethod(PHPExcel_Shared_Font::AUTOSIZE_METHOD_EXACT);
If a worksheet contains formulae, then some versions of MS Excel files hold additional information detailing the calculation tree: data that is not saved by PHPExcel (because calculating the tree structure is a big overhead). You don't indicate which format you are using to save your workbooks, or which version of MS Excel you're using to open them; but this is the normal explanation for any prompting to save changes when a PHPExcel-generated file is opened in MS Excel.
It works for me if you paste it just before saving the file, like this:
$objWriter->setPreCalculateFormulas(true);
$objWriter -> save("file.xlsx");
We get an excel worksheet from a customer and there is a data discrepancy with one of the col. the item description they send. We want to programmatically open the document lookup the table using item column, and then write a new column with the item description from the table (on SQLSever) that part of getting the data is fine but how to create such a new column is where I am stumped. writing in asp.net but open to however it can be done
I am getting this error when trying to insert a column:
To prevent possible loss of data, Excel cannot shift nonblank cells
off of the worksheet. Select another location in which to insert new
cells, or delete data from the end of your worksheet.
If you do not have data in cells that can be shifted off of the
worksheet, you can reset which cells Excel considers nonblank. To do
this, press CTRL+End to locate the last nonblank cell on the
worksheet. Delete this cell and all cells between it and the last row
and column of your data then save.
This problem is not linked to your code, it happens when you have data on the last column (and so Excel do not want you to loose it).
Yet, the trick is Excel considers that any style is the same as data. So, if you have ever defined a style on the whole row, inserting a column may cause this error.
Let me give an example to explain it more:
Create a new Excel workbook
Select the whole first row
Paint it in Yellow (or whatever color)
Select cells from A1 to E1
Paint them in white
Try to insert a new column before B
You get the error because Excel does consider that you wanted to define a specific style to the last cell so you would loose this information if you inserted a new column
Have a look at your file to solve this issue (IMHO, defining style on a whole row is a bad practice because it could cause this kind of error).
Yeah I often get this annoying bug bothering me.
To avoid this behavior in Excel 2007, what you do is you go to the end of your data with CTRL+end.
Then you go one cell down (or one cell right if you are at the bottom), and copy this cell ( CTRL+c), that should be blank, since your outside your data.
Then go back to the place where you (not that stupid Excel) consider your data should stop, while holding the shift key, and paste it (CTRL+v).
After this you should be able to insert that column.