Google Sheets API with Python, border check - python-3.x

Is there any way to check that is current cell in sheet has a bold border? I want to use this to separate areas
I only found how to change it, not to check. thats not cool

Related

XSSF worksheet cells having random styles

Is there any way to set style for all next cells in excel worksheet? Like for the rest of the document after certain cell?
I am using Apache POI 3.9 for exporting data to excel worksheet. Client wants colored font for invalid data. Everything is running fine, but sometimes, when I put text in empty cells in "INFORMATION" column, it makes font colored red, even after reseting cell style or explicitly asking for condition and then setting default cell style. Youre more likely to get my idea from pic of code.
Ive uploaded some pic of excel too. Hope it helps. It starts on row 37, text somehow changes color even after not running through setting conditions. I havent recognized any pattern in there.
I tried to change conditions, change cell style setting location in code... Had no effect.
Edit: It seems like the problem is not in AP but in Excel itself. It looks like the font color is changed after user input and its caused by autoformatting that is based on the context. So only option here is to change style of previous data. Could not find any other solution to this.

Is there a way to make Conditional Formatting ignore the FollowedHyperlink flag?

I have a table of contents in Excel 365. In the table, column 2 contains the names of worksheets and column 3 contains the names of tables and/or named ranges in the associated worksheet. I used the HYPERLINK function to link each cell to its specific component: hyperlinks for the worksheet column go to cell A1 on the associated worksheet; hyperlinks in the table/named range column go to that specific table or named range.
Since this results in several repeats of worksheet names, I used conditional formatting to change the text to white when the worksheet name is a repeat of the one directly above it. This makes it look more like an outline. It works like a charm up until the point that I click on the link in a repeated cell, making it a FollowedHyperlink. When I return to the table, this is no longer whited out. Is there a way to make these stay white, even after they've been followed?
Here's the formula I used for the conditional formatting rule applied it throughout the range =$C$6:$C$24:
=C5=C6
Here's what it looks like before I click one of the whited-out cells:
Here's what it looks like after I click one of the whited-out cells:
Urdearboy posted a link showing how to change the style of a followed link.
https://superuser.com/questions/728825/how-do-i-prevent-excel-from-changing-the-color-of-a-clicked-link/819931#819931
It is probably the best solution without using VBA.
But if you want some not control over it, if for example, you may want all links in a table if contents to be uniform color regardless if they were taken or not, but you want links in the rest of the book to change. That's as easy as a single line of VBA in the worksheet's SheetFollowHyperlink event:
Target.Range.Font.Color = vbBlue
And if you wanted to apply it to the entire workbook instead of a single sheet you would put it in the workbook's SheetFollowHyperlink event.
But if you want to be a little creative...
You could make the link disappear by blending it with the background color:
Target.Range.Font.Color = Target.Range.Interior.Color
Or you can draw attention to it, by changing the back color:
Target.Range.Interior.Color = vbYellow
Really, your imagination is the only limit. You can do just about anything you'd ever want to do ( and a lot more of things you would never want to do).

Get the current Fill Color

How can I get the current Fill Color in the ribbon using VBA? I like to manually select the Fill color to highlight entire rows with. I know I can highlight an entire row with code like foo.EntireRow.Interior.ColorIndex = 3. However, instead of setting it to 3, I want to set it to the user's currently selected Fill Color in the ribbon.
I found a similar thread for Microsoft Word that uses Options.DefaultHighlightColorIndex, but I have not found one for Microsoft Excel.
Edit: Sorry for the duplicate question. I am hoping there’s a better answer that doesn’t require an active selection first. If not I’ll accept Jonathan’s answer. Currently I am just highlighting the current cell with CellFillColorPicker, getting that cell’s color and then highlighting the row with that color.
This question appears to be similar to this one: VBA - use color already select in Excel to fill cell interior
It looks like this is the code that you want:
Application.CommandBars.ExecuteMso "CellFillColorPicker"

Excel-VBA Get Code of the design of existing cells

For an application of protocolling some measurements and therefore made a design for the print out of the data. This is a fairly complex design with many highlighted area, marked cells, font size changes, background color, pictures and so on.
My question is: Is there any way to get the design as a VBA code to "store" it without doing it all manually?
I already tried around some with the macro, though I couldn't "read" the current cell design.
Thank you in advance
You could save your empty templates on hidden sheets and copy the required on to the "print" sheet. Storing all of the formatting in code will be difficult to manage unless it's very basic formatting.

How to change the tab color based on a cell in the worksheet?

I have a very large spreadsheet with lots of worksheets that I use to create invoices based on a project number. Each project doesn't get billed on a monthly basis. I have to print each invoice to PDF and to avoid having to open every tab to see if there is information to bill, I'd like to change the tab color based a cell which contains the total of the invoice.
I have used VBA very little but have found several macros that are trying to do the same thing but because they rely on something different, I can't get what I need. I found one that just turns all the tabs a color. I found one that changes the color based on a true/false formula. I don't have the knowledge around this code to change it so that if cell H22 is >0, it turns the tab a color.
The invoices created before I took my role aren't consistent so not all totals will be in cell H22 -- it could be H14. I'm even willing to put a button on each tab that I could press to apply the macro as I do my preliminary work on each tab. I just don't have the knowledge good enough to know how to write the code. Thanks!
The easiest way would be to find an cell that none of the worksheets use (say AZ99) and do the equivalent of the H22>0 example you described on each sheet.
e.g sheet1 might have AZ99 as X10>0, sheet2 might be Y11>0 or whatever.
Use the true/false VBA code to look at cell AZ99 or whatever the cell you choose is.

Resources