Issue 128567 - References to columns above 676 are wrong when importing XML files
Summary: References to columns above 676 are wrong when importing XML files
Alias: None
Product: Calc
Classification: Application
Component: code (show other issues)
Version: 4.1.14
Hardware: PC Windows, all
: P5 (lowest) Major with 1 vote (vote)
Target Milestone: ---
Assignee: AOO issues mailing list
QA Contact:
Depends on:
Reported: 2023-03-18 01:07 UTC by alex6684
Modified: 2023-03-25 16:06 UTC (History)
4 users (show)

See Also:
Issue Type: PATCH
Latest Confirmation in: ---
Developer Difficulty: ---
mseidel: 4.1.15_release_blocker?

Example file demonstrating the error. (6.96 KB, application/x-zip-compressed)
2023-03-18 01:07 UTC, alex6684
no flags Details
ODS file created by opening the xml with with calc (23.71 KB, application/vnd.oasis.opendocument.spreadsheet)
2023-03-25 16:00 UTC, Keith N. McKenna
no flags Details

Note You need to log in before you can comment on or make changes to this issue.
Description alex6684 2023-03-18 01:07:32 UTC
Created attachment 87177 [details]
Example file demonstrating the error.

File spreadsheetml2ooo.xsl has already been patched in version 4.1.14 (Issue 81233) but now references columns above 676 are wrong. Below is a patch for spreadsheetml2ooo.xsl replacing templates translate-unit and number-to-character.
Files uof2odf.xsl and uof2odf_spreadsheet.xsl contain a wrong version of translate-unit as well.

	<xsl:template name="translate-unit">
		<!-- convert cell position expression unit, R1C1, R3, C4 -->
		<xsl:param name="column-number"/>
		<xsl:param name="row-number"/>
		<xsl:param name="column-pos-style"/>
		<xsl:param name="row-pos-style"/>

		<xsl:variable name="ColumnLetters">
			<xsl:call-template name="ConvertColumnNumber">
				<xsl:with-param name="ColumnNumber" select="$column-number"/>

		<!-- position styles are 'absolute' or 'relative', -->
			<xsl:when test="$column-pos-style = 'absolute'">
		<xsl:value-of select="$ColumnLetters"/>

			<xsl:when test="$row-pos-style ='absolute'">
		<xsl:value-of select="$row-number"/>

	<xsl:template name="ConvertColumnNumber">
		<xsl:param name="ColumnNumber"/>
		<xsl:variable name="letters" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
			<xsl:when test="$ColumnNumber &lt;= 26">
				<xsl:value-of select="substring($letters, $ColumnNumber, 1)"/>
				<xsl:call-template name="ConvertColumnNumber">
					<xsl:with-param name="ColumnNumber" select="floor(($ColumnNumber - 1) div 26)"/>
				<xsl:value-of select="substring($letters, ($ColumnNumber - 1) mod 26 + 1, 1)"/>
Comment 1 Keith N. McKenna 2023-03-25 16:00:06 UTC
Created attachment 87181 [details]
ODS file created by opening the xml with with calc

The attached ODS file shows the results of opening the XML file with Calc. From 677-702 are incorrect, then from 703-1024 are again correct.
Comment 2 Keith N. McKenna 2023-03-25 16:06:51 UTC
Confirmed  with the following configuration:
Windows 10
Microsoft Windows
Version 22H2 (OS Build19044-2604)

Apache OpenOffice® 4.1.14
AOO4114m1(Build:9811)—Rev. a0d24fb625
2023-02-08 19:47

Columns 677-702 are incorrect, columns 703-1024 are again correct.