Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline strings are not written into spreadsheet. #353

Closed
PowerGamer1 opened this issue Jan 30, 2018 · 7 comments
Closed

Inline strings are not written into spreadsheet. #353

PowerGamer1 opened this issue Jan 30, 2018 · 7 comments
Labels
bug enhancement help wanted writer/xlsx Writer for MS OfficeOpenXML-format (xlsx) spreadsheet files

Comments

@PowerGamer1
Copy link

What is the expected behavior?

The generated spreadsheet contains text 'inline str' in A1 cell. The text appears directly in the cell inside sheet1.xml (and not in sharedStrings.xml).

What is the current behavior?

A1 cell of generated spreadsheet is empty.

What are the steps to reproduce?

<?php
require __DIR__ . '/vendor/autoload.php';
$doc = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
$sheet = $doc->getSheet(0);
$sheet->getCellByColumnAndRow(1, 1)->setValueExplicit('inline str', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_INLINE);
$sheet->getCellByColumnAndRow(2, 1)->setValueExplicit('shared str', \PhpOffice\PhpSpreadsheet\Cell\DataType::TYPE_STRING);
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($doc, 'Xlsx');
$writer->save('1.xlsx');

Which versions of PhpSpreadsheet and PHP are affected?

1.0.0.

When a cell value is set with a DataType::TYPE_INLINE the writer should write such string into the spreadsheet as inline string (which goes directly into the content of a cell rather than shared string table). See 18.3.1.4 and 18.18.11 in ISO/IEC 29500-1 for more info.

@PowerKiKi
Copy link
Member

I can confirm what you described. But what is the use-case for using inline strings instead of shared one ?

@PowerGamer1
Copy link
Author

  1. According to spec inline string MUST be placed into the cell itself, not string table, so as long as your library allows setting string type as inline it must adhere to spec when writing such strings into XML - and use case does not matter.

  2. The whole point of shared string table is to save memory for string storage in case your worksheet has many instances of the same string in different cells. Putting there a string that appears in a single cell only and never repeats in any other cell would not only be pointless but also unnecessary increase shared string table size which might increase the lookup speed in shared string table.

@PowerKiKi
Copy link
Member

That seems fair. If this is important to you, please consider contributing a PR for it. In the meantime we can probably workaround it by using shared strings.

@PowerKiKi PowerKiKi added bug enhancement help wanted writer/xlsx Writer for MS OfficeOpenXML-format (xlsx) spreadsheet files labels Feb 11, 2018
@eltharin
Copy link

Hi,
It's possible to want to open files using inline strings and for the moment the return is null.

@PowerKiKi
Copy link
Member

@eltharin this would be a different issue, please consider opening a new issue, or better yet contributing a patch for it.

@stale
Copy link

stale bot commented Apr 23, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
If this is still an issue for you, please try to help by debugging it further and sharing your results.
Thank you for your contributions.

@oleibman
Copy link
Collaborator

oleibman commented Jul 5, 2024

Fixed by PR #2569.

@oleibman oleibman removed the stale label Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug enhancement help wanted writer/xlsx Writer for MS OfficeOpenXML-format (xlsx) spreadsheet files
Development

No branches or pull requests

4 participants