PHPOffice / PhpSpreadsheet

A pure PHP library for reading and writing spreadsheet files
https://phpspreadsheet.readthedocs.io
MIT License
13.25k stars 3.42k forks source link

Theme added to the table, cant be fetched in the functionality #4078

Open bokrma opened 2 months ago

bokrma commented 2 months ago

hello, am trying to fetch the theme styles related from the following file, but didn't find any functionality to be able to do that

-theme: "Reponsibles-style" test table with styles (1).xlsx

can you please help me to fetch the details of the style of the theme

oleibman commented 2 months ago
$theme = $spreadsheet->getTheme();
// then use any of the methods in Theme do get the information you need
bokrma commented 2 months ago

no not the default theme of the whole workbook I mean the theme styles for the table it self like the colors for the columns and etc... because currently its not fetching the table related stylings I can only get the theme name which is not the default theme of the whole excel file

oleibman commented 2 months ago

Hmm. Sorry for the misunderstanding. At any rate, you can get the name of the style easily enough:

$themeStyleName = $table->getStyle()->getTheme();

But I don't see anywhere in the spreadsheet where the actual styles used for that theme name are defined.

Now, if you have modified the theme for your table, I do see an entry in styles.xml for the specific parts of the style that you have overridden, e.g.

<tableStyles count="1" defaultTableStyle="TableStyleMedium9">
<tableStyle name="Table Style 1" pivot="0" count="1" xr9:uid="{38CE2BF8-AFBD-49CD-821A-24E92973F8A1}">
<tableStyleElement type="secondRowStripe" dxfId="0"/>
</tableStyle>
</tableStyles>

We do not currently process these tags. You might consider opening a feature request for this. It would probably be a bit of a challenge to implement, and we would probably not be able to provide the actual values for the parts of the style that you don't override. But perhaps you wouldn't need those, if, say, all you wanted to do with these is to use the same overrides on write that we were able to detect on read.

bokrma commented 2 months ago

the idea is, all the styles for this table is not showing,please try to open it using excel sheet app, or google sheet online you can see the difference am talking about when I try with the library to get those styles, am not able to do that at all so in this case the whole table has set of styles but couldn't fetch them anyhow

oleibman commented 2 months ago

As I said, I cannot find the table style details (except name) anywhere in the spreadsheet file. If you can, please let me know how.

bokrma commented 2 months ago

I will look into the zipped file to see where are the values saved

bokrma commented 2 months ago

ok you are right, there is no styles or theme defined for the one i asked you about, but then another question, how to know which default style selected for the table from the following:

Screenshot 2024-07-03 at 14 01 14
bokrma commented 2 months ago

do you have any idea about my last comment?

oleibman commented 2 months ago

I can tell what the default table style name is for a spreadsheet. Would that be useful enough for your purposes?