How to copy conditionally formatted cells from Calc as a table into Writer - formatting

I have a LibreOffice Calc spreadsheet that uses some conditional formatting of cells. I would like to copy it into Writer as a table. The colours/formats of the cells should remain as they were due to the conditional formatting in Calc. Unfortunately when I do that, the formatting vanishes.
How can I copy it keeping the formatting?
Of course the Writer version no longer has to be conditional, but I need to keep current colours.
My work is done so eventually I can do the trick in Calc first (abandon the "conditional" part, and just preserve the formatting as - is). However due to amount of data I would prefer not to do it manually.
Is macro the only way to do that?

Use Insert -> Object -> OLE Object
Choose Create from file
Pick the right .ods file.
If you want to modify further (in my case - I need to create many tables from one spreadsheet as the original file is humongous - up to CL column) - do not tick "Link to the file" option.
After pressing OK, the spreadsheet is inserted as is (cloned and embedded), with the conditional formatting. Can be further modified (e.g. rows/cols can be deleted, hidden or whatever is needed). The conditional formatting remains active.

I personally prefer to copy as an image. This ensures the format is always exactly as it was in the spreadsheet and that no weird OLE/DDE links go wrong.
However, you specifically ask for a table. For that there are three (or 2.5) options:
Insert the entire as spreadsheet as an object. In Windows that can be done as Ister describes in his answer. This will be editable as an inline mini-sheet (Writer will invoke Calc for any editing actions).
Insert a part of the sheet as an object: Select what you want in the document, copy to the clipboard, go to Writer and select Edit->Paste Special. Then select the OLE option, or if on Linux, select "calc8". This will be editable as an inline mini-sheet.
Insert as HTML. This creates a standalone table. Formatting will not be 100% as in the sheet, as fonts, etc, will be reset by Writer, but it is a native Writer table that you can manipulate in Writer without invoking Calc. Colors, etc, are preserved.
If you use any of the object embedding options, you'll notice that formulae are kept intact (when not referring the data outside the pasted sheet or region). If you want all the data to be verbatim, then you need an intermediate step:
Select the data in your original sheet that you wish
Copy to the clipboard
Create a new sheet and place the cursor in the same spot as the first cell of the copied data (e.g. if your copied region is B4:X99, then place the cursor in B4 of the new sheet)
Select Edit->Paste Special
In the Paste Special window, check only the following options and click OK:
Text
Numbers
Date & Time
Formats

Related

Is there a way to copy an entire Spreadsheet with only values and no formulas/links (Google Sheets)?

The issue I am facing is trying to automate my weekly occurrence of coping an entire Spreadsheet to make a copy of it. Each week I need to hit "File --> Make a copy --> share with same people" and after doing so on the copy I need to hit "Allow Access" multiple times for each table that requires access, if I do not do this, there is no data displayed.
So I am wondering if there is a way to create a copy of a Spreadsheet where the copy contains entirely plain text and no formulas or links that way all the data can be read as soon as a copy is made.
This could be a separate question, but if anyone also knows how to automate hitting the "allow access" button for multiple tables in the copy that would also be helpful.
*To give an idea of the layout, essentially I have a main Spreadsheet (the one I make a copy of) that references data from other Spreadsheets (that are linked to google forms), and then I make a copy of the main Spreadsheet, and in making this copy is where I am required to hit the access button for each table.
Answer:
You can do this with Apps Script.
Code Example:
function duplicateSpreadsheet() {
const idOfSheetToCopy = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
var file = DriveApp.getFileById(ifOfSheetToCopy).next()
const newFile = file.makeCopy()
SpreadsheetApp.openById(newFile.getId()).getSheets().forEach(function(sheet) {
sheet.getDataRange().setValues(sheet.getDataRange().getDisplayValues())
})
}
Code Rundown:
Define Template Sheet ID
Make a copy of the sheet using DriveApp
Get the ID of the newly created sheet and open it with SpreadsheetApp
Loop through all sheets in the new copy and replace all cell values for the cell's display value
Instead of pasting with "Ctrl+V" use "Ctrl+Shift+V" for pasting without formatting. This will ignore things like links, font, and font size.
Not sure about the allow access button.

How can I create 600+ copies of a word doc, using a naming convention from a spreadsheet?

I have a list of 600 names in a spreadsheet, and I want to quickly create a Word Doc for each with the name in the filename.
I work on a Mac.
Create a formula for the required commands.
The result of the formula should be:
cp "/path/to/original.docx" "/path/to/copy-filename.docx"
So for example, if you want the copy to be called "copy-" then the contents of the A column, the formula might be:
="cp ""/path/to/original.docx"" ""/path/to/copy-" & A1 & ".docx"""
Then fill down the formula down the spreadsheet to create the commands.
Then you can copy the formula result and paste it into a text editor to check it is correct. Once you are satisfied it is correct, you can paste it into a terminal window and the commands will be executed.
If this is a one-off task, this is what I suggest. If you need to do this hourly then you should probably do something different involving a VBA macro.

Make small changes to multiple functions without affecting cell reference

What is the best way to change ">" to ">=" in 100+ formulas such as:
=IF(INDEX($B$2:$B$46,MATCH(A3,$D$2:$D$46,0))**>**$A$2),"1","0")
=IF(INDEX($B$2:$B$46,MATCH(A3,$D$2:$D$46,0))**>**$B$2),"1","0")
=IF(INDEX($B$2:$B$46,MATCH(A3,$D$2:$D$46,0))**>**$C$2),"1","0")
Would I need some VBA code?
I would suggest one more idea if you are not comfortable doing the find and replace in excel.
Press the key combination Ctrl+` (BackQuote symbol)
Now you will have all the formulas visible in the cells.
Copy the range or columns in which you need to modify the formula
Paste it in a .txt file and then do the find and replace
Once it is done copy all the formula and paste it back to the same range.
Press Ctrl+` again and now you have got all the formulas changed as per your need
As long suggested, take a backup of your worksheet before you do these modifications
As Scott_Craner stated, a simple Find/Replace should work.
Save a version of your data in case you misjudged where the search subject is in your data.
Highlight the cells with the formulas you wish to change.
Press Ctrl and the F keys (or click on "Find&Select" in the Home tab in the "Editing" group and select Replace from the drop-down)
In the Find and Replace dialog box, make sure you are on the Replace tab.
In the "Find what:" box, type ">" without quotes (note, if there are other > symbols in some formulas, you can distinguish these with some repetitive text before and after)
In the "Replace with:" box, type "<" without quotes (note, if you included other text to specify certain instances of ">", make sure you include all the text that should also be replaced)
Hit the "Replace All" button.
Your spreadsheet formulas should now be as you'd like them. If they're not, thank goodness you saved another version first. Find/Replace is very powerful, so make sure to limit the scope by selecting the cells you want searched and being sure that Excel will find only those data you wish to change.
If you are interested in VBA, you could use it here. But Excel already has a powerful, user-friendly tool at your disposal.

vba command to paste special KeepSourceFormatting(K) in powerPoint

i am trying to take a cell range from excel and copy it to powerpoint2010. However I do not want to use the Embedded format but rather the KeepSourceFormatting one. I tried the following command
ActiveWindow.View.PasteSpecial DataType:=ppPasteOLEObject, Link:=msoFalse
but this still creates an object that launches excel to edit the contents.
basically I want to paste a table of formated data from excel to powerpoint and maintain its appearance but still be able to edit the contents in powerpoint.
any ideas?
There are following options for DataType:
ppPasteEnhancedMetafile which allows edition each of separate field of the table (rather pure solution)
ppPasteMetafilePicture similar option
ppPasteOLEObjectwhich you know
I can't see any other option.

Convert xls File to csv, but extra rows added?

So, I am trying to convert some xls files to a csv, and everything works great, except for one part. The SaveAs function in the Excel interop seems to export all of the rows (including blank ones). I can see these rows when I look at the file using Notepad. (All of the rows I expect, 15 rows with two single quotes, then the rest are just blank). I then have a stored procedure that takes this csv and imports to the desired table (this works on spreadsheets that have been manually converted to csv (e.g. open, File--> Saves As, etc.)
Here is the line of code I am using for my SavesAs in my code. I have tried xlCSV, xlCSVWindows, and xlCSVDOS as my file format, but they all do the same thing.
wb.SaveAs(aFiles(i).Replace(".xls", "B.csv"), Excel.XlFileFormat.xlCSVMSDOS, , , , False) 'saves a copy of the spreadsheet as a csv
So, is there some additional step/setting I need to do to not get the extraneuos rows to show up in the csv?
Note that if I open this newly created csv, and then click Save As, and choose csv, my procedure likes it again.
When you create a CSV from a Workbook, the CSV is generated based upon your UsedRange. Since the UsedRange can be expanded simply by having formatting applied to a cell (without any contents) this is why you are getting blank rows. (You can also get blank columns due to this issue.)
When you open the generated CSV all of those no-content cells no longer contribute to the UsedRange due to having no content or formatting (since only values are saved in CSVs).
You can correct this issue by updating your used range before the save. Here's a brief sub I wrote in VBA that would do the trick. This code would make you lose all formatting, but I figured that wasn't important since you're saving to a CSV anyway. I'll leave the conversion to VB.Net up to you.
Sub CorrectUsedRange()
Dim values
Dim usedRangeAddress As String
Dim r As Range
'Get UsedRange Address prior to deleting Range
usedRangeAddress = ActiveSheet.UsedRange.Address
'Store values of cells to array.
values = ActiveSheet.UsedRange
'Delete all cells in the sheet
ActiveSheet.Cells.Delete
'Restore values to their initial locations
Range(usedRangeAddress) = values
End Sub
Tested your code with VBA and Excel2007 - works nice.
However, I could replicate it somewhat, by formatting an empty cell below my data-cells to bold. Then I would get empty single quotes in the csv. BUT this was also the case, when I used SaveAs.
So, my suggestion would be to clear all non-data cells, then to save your file. This way you can at least exclude this point of error.
I'm afraid that may not be enough. It seems there's an Excel bug that makes even deleting the non-data cells insufficient to prevent them from being written out as empty cells when saving as csv.
http://answers.microsoft.com/en-us/office/forum/office_2010-excel/excel-bug-save-as-csv-saves-previously-deleted/2da9a8b4-50c2-49fd-a998-6b342694681e
Another way, without a script. Hit Ctrl+End . If that ends up in a row AFTER your real data, then select the rows from the first one until at least the row this ends up on, right click, and "Clear Contents".