How to apply conditional format to odt file? - libreoffice

I need to evaluate a cell on a table on a odt, file, and apply conditional format if value is > 0.
Not in speedsheet, is for writer

Tested with LO 5.4 and 6.0.4 on Win 10:
IMHO, the best solution is to insert a LO Calc spreadsheet as "OLE Object" into the odt file. This gives you the complete Calc funtionality inside Writer.
To do so, put the cursor to where the table should appear. Select Menu "Insert" -> "Object" -> "OLE Object". In the following window, select "New" and "LibreOffice 6.0 Spreadsheet". Alternatively, you may insert an already-existing Calc table.
After clicking OK, the object will appear, and it's already activated (you can determine if it's active by the thick gray border and the row/column heads - you can "deactivate" it by clicking outside, anywhere in the Writer document; you can re-activate the Calc object by double-clicking inside its borders).
Now, you can edit the Calc table as usual. Notice that the Menus will adapt to the Calc features if the Calc OLE object is active. So, e.g. the "Format" Menu will only contain a "Conditional formatting" entry if the Calc OLE object is active.
Here are some screenshots:
Insert a OLE object in Writer:
Writer document with embedded Calc table:
Applying conditional formatting to some content of the embedded Calc sheet:
Resulting Writer document with conditionally-formatted Calc table (Calc object is active):
Same as 4, now Calc object is inactive:

Related

LibreOffice Calc - how to drag-fill a series from multiple rows that all reference the same row

I have cells in a few rows that all reference one row on another sheet:
=Sheet2.A1
=Sheet2.B1
=Sheet2.C1
When I select these cells and drag the fill handle to fill the cells below, Calc fills them like this:
=Sheet2.A4
=Sheet2.B4
=Sheet2.C4
=Sheet2.A7
=Sheet2.B7
=Sheet2.C7
etc.
I guess it's doing this because each new row is three cells below the original row.
This is not the behaviour I want - I want to fill them in a series, like this:
=Sheet2.A2
=Sheet2.B2
=Sheet2.C2
=Sheet2.A3
=Sheet2.B3
=Sheet2.C3
=Sheet2.A4
=Sheet2.B4
=Sheet2.C4
etc.
Any ideas how to do this?
I'd like to use either a formula or a manual way of doing this - I'm not familiar with macros so would rather avoid if possible, please.
Manual way (I like that suggestion, I never even thought about using Calc to automatize the process of filling in spreadsheet formulas before, but it's doable):
Open a new Calc file
Format cell A1 as text
type =Sheet2. into A1 (A1 should now display =Sheet2. literally)
type A B C into B1, B2 and B3 respectively
select B1 to B3 and drag down (it should repeat series A,B,C,A,B,C...)
type =FLOOR((ROW()-1)/3)+2 into C1 (ROW() starts counting from 1 hence the -1)
drag that down (it should give you the series 2,2,2,3,3,3,4,4,4...)
type =A$1&B1&C1 into D1 (D1 should now display =Sheet2.A2 literally)
drag D1 down and it should give you your desired series
NOW: copy that
paste it into any notepad or similar plain text editor
copy that
paste it into the Calc spreadsheet you wanted to have this series of references in first place
it should open a text import dialogue - just make sure everything is pasted into one column and hit OK
VoilĂ 
pros: when your colleagues see you do that you will be seen as LibreOffice god from now on
cons: not very dynamic (you'll have to repeat the whole process if something changes)
Formula way:
Use OFFSET.
E.g: =OFFSET(Sheet2.$A$2;FLOOR((ROW()-1)/3);MOD(ROW()-1;3))
pros: easier to modify
cons: if the results are not what you're expecting, it's harder to debug

Cross-reference list is empty in Word 2010

I have been given a Word file (.docx) that has about 35 figures and tables. When I try to add a cross-reference I get an empty list like this:
I made sure that:
1) The figures and tables are actually captions. If I delete anyone of them, the rest get updated as expected.
2) Other cross-references already in the file works. They get updated correctly like in (1)
3) The document doesn't have any 'track changes'. This is apparently a problem for some people, so I did an 'accept all changes'. Doesn't seem to help unfortunately.
4) I tried copy all and paste into a new file.
5) I tried selecting all and F9.
I'm perplexed why this is happening. Anyone can help me find the root cause?
I know that it is probably late, but maybe it will help somebody else.
Select caption below table/picture
Right click and select Toggle field codes - the caption show the code in format like SEQ xxx xxx
Go to Insert -> Reference -> Caption and click on New Label button
Insert the text following after SEQ from point 2. E.g. Fig.
Save the new label.
Go to Insert -> Reference -> Cross Reference - select the inserted value from point 4 in the Reference type dropdown list. Now you should see all the values.
The answer is based on the following link.
In Word 2013, instead of Insert>Reference>Caption, right click on a figure or table and select insert caption. A dialogue box including the option New Label will appear.
In my case, I think this issue arose because of changes in language. The tables are all captioned with the French Tableau, but in insert references, it had Table and a blank list.

Insert a table in an unalterable format into a Word 2010 file while retaining font size and sharpness

I am trying to insert a table in an unalterable format into a Word 2010 file while retaining font size and sharpness.
So far, I have tried preparing the table as a pdf, then using Insert -> Object -> Adobe Acrobat File to get it into Word. Unfortunately, this inserts the table within margins automatically created on the Word page, and distorts lines and font size within the table.
Here are some things I've tried:
- Setting the margins of the page in the recipient Word file to 0" before importing the pdf.
- Printing the pdf on on a smaller page (7" x 9") then importing onto a page 8.5" x 11".
Neither worked; the imported pages were resized and the table printed badly.
The pdf I used was prepared from Word using PrimoPDF.
Please feel free to suggest formats other than pdf for the transfer if they can be more easily incorporated into the final Word document.
Your help will be appreciated.
First, prepare the table as a Word document. Go to the Review tab, and select Restrict Editing. Set Editing Restrictions to allow No changes (Read only). Press Yes, Start Enforcing Protection. Save file.
Next prepare the recipient document in Word. Go to the Insert tab, select Object, Create from File, and browse to find and insert the file.
The table will be inserted into the recipient Word file as a document within a document, and its 'Read Only' protection is maintained. All fonts and line styles remain as originally set.

How to Handle Tcl Treeview Selections

I am using the following procedure to delete a record within a database that is displayed within a treeview widget (z1):
set z1 [ttk::treeview .c1.t1 -columns {first last} -show headings]
proc Dlt {} {
global z1 z11
sqlite3 db test.db
db eval {
DELETE From t1 Where First_Name = $z11 and Last_Name = $z11
}
db close
}
$z11 in the sql statement should be the treeview selection. Unfortunately, I cannot figure out how to set a variable to equal the treeview selection. I can set a variable to equal the index, which is: set z11 [$z1 index [$z1 selection]]. This will give me the index of the treeview selection; however, I am trying to get the string value of the treeview selection.
Does anyone know what the correct syntax is to set a variable to equal a treeview selection?
Thank you,
To get the values for an item in the tree you would use the item subcommand of the tree. For example:
set selection [.tree selection]
set text [.tree item $selection -text]
This is all documented on the man page for the treeview widget.
As an aside, what platform are you working with? If Windows, for debugging purposes, you can add a "console show" command to your code to display an interactive console window. With that open, you can just use [puts] to display variable values. So, you could just use "puts $text" (from within your code) to see the value of your text variable.
Also, you can just type commands directly into the console for immediate evaluation. In many situations, spending a few minutes in the console can be very enlightening.
If you're not running under Windows, you don't even need the "console show" command, as anything written to stdout should appear in the original shell window.

How do I create a text file so when it is opened in Excel, rows are grouped together?

I'm collecting some data via a Perl script. The data needs to be reviewed and processed by others using Excel. Currently, I'm writing the data out as a tab-delimited text file, and Excel can open this just fine.
There's a hierarchy to the data, however, and it would be easier for the reviewers to see a tree rather than a flat list. That is, rather than presenting the data in columns,
foo foo1
foo foo2
foo foo3
bar bar1
bar bar2
...
present it as a click-to-expand tree:
foo
foo1
foo2
foo3
bar
bar1
bar2
...
Excel's group function (found in 2007 under "Data > Outline > Group") is a good match for this presentation, being a bit simpler to operate than pivot tables.
What is the easiest way for us to go from this flat list of columns to this grouped list? Ideally, I could write out the data in a text form that Excel would apply the grouping automatically when it was imported. Alternatively, if there were a small number of steps the reviewer could apply after importing the data, like applying a macro or a template, that would be OK too.
Since you are already using perl, I suggest that you create the excel file directly in perl using the excellent CPAN module Spreadsheet::WriteExcel which has support for Excel outlines.
Works something like this:
.
.
$worksheet->write('A2', 'foo');
$worksheet->write('B3', 'foo1');
$worksheet->write('B4', 'foo2');
$worksheet->write('B5', 'foo3');
$worksheet->set_row(2, undef, undef, 0, 1, 1);
$worksheet->set_row(3, undef, undef, 0, 2);
$worksheet->set_row(4, undef, undef, 0, 2);
$worksheet->set_row(5, undef, undef, 0, 2);
.
.
Select all the rows, including the column headers, in the list you want to filter.
ShowTip
Click the top left cell of the range, and then drag to the bottom right cell.
On the Data menu, point to Filter, and then click Advanced Filter.
In the Advanced Filter dialog box, click Filter the list, in place.
Select the Unique records only check box, and then click OK.
The filtered list is displayed and the duplicate rows are hidden.
On the Edit menu, click Office Clipboard.
The Clipboard task pane is displayed.
Make sure the filtered list is still selected, and then click Copy Copy button.
The filtered list is highlighted with bounding outlines and the selection appears as an item at the top of the Clipboard.
On the Data menu, point to Filter, and then click Show All.
The original list is re-displayed.
Press the DELETE key.
The original list is deleted.
In the Clipboard, click on the filtered list item.
The filtered list appears in the same location as the original list.
Recent versions of Excel (2003 is what we use here) can use an XML format, xlsx. An xlsx file is a zip of an XML file. If you want to make a file that will open in Excel with the settings you want, try this: first create a template file with the grouping you want. Save it as xlsx. Unzip the file using your standard zip software. Take a look at what's inside. I haven't worked with grouping specifically, but all the commands in your spreadsheet will be there in xml form, you'll need to figure out where the grouping is set. Then it's a matter of making the appropriate changes to the xml and re-zipping. A bit of effort, but you can use this method to programmatically create files that are pre-grouped. There may be Perl libraries specifically geared towards this, I don't know.
A CSV file is also very easy to generate. OpenOffice lets you choose how to parse things, but excel excepts comma-delimited columns (without any kind of quote) and CRLF delimited rows.
A1,A2,A3
B1,B2,B3
etc.