This is an automated email from the ASF dual-hosted git repository.

bamaer pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git


The following commit(s) were added to refs/heads/main by this push:
     new 97ef6a06a0 Excel writer: no NullPointerException on an empty lazily 
converted va… (#9517)
97ef6a06a0 is described below

commit 97ef6a06a02d089ec31a0aa66874bdc781c494ec
Author: Hans Van Akelyen <[email protected]>
AuthorDate: Tue Nov 17 09:46:23 2026 +0100

    Excel writer: no NullPointerException on an empty lazily converted va… 
(#9517)
    
    * Excel writer: no NullPointerException on an empty lazily converted value, 
fixes #9508
    
    * fix remarks
---
 .../spreadsheet/0014-check-lazy-empty-values.hpl   | 168 ++++++++++++++++
 .../spreadsheet/0014-write-lazy-empty-values.hpl   | 213 +++++++++++++++++++++
 .../datasets/golden-excelwriter-lazy-empty.csv     |   3 +
 .../spreadsheet/files/excelwriter-lazy-empty.csv   |   3 +
 .../main-0014-excelwriter-lazy-empty.hwf           | 114 +++++++++++
 .../dataset/golden-excelwriter-lazy-empty.json     |  32 ++++
 .../0014-check-lazy-empty-values UNIT.json         |  36 ++++
 .../excelwriter/ExcelWriterTransform.java          |  11 +-
 .../excelwriter/ExcelWriterTransformTest.java      |  31 +++
 9 files changed, 607 insertions(+), 4 deletions(-)

diff --git a/integration-tests/spreadsheet/0014-check-lazy-empty-values.hpl 
b/integration-tests/spreadsheet/0014-check-lazy-empty-values.hpl
new file mode 100644
index 0000000000..cb2ad4c4be
--- /dev/null
+++ b/integration-tests/spreadsheet/0014-check-lazy-empty-values.hpl
@@ -0,0 +1,168 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<pipeline>
+  <info>
+    <pipeline_version/>
+    <capture_transform_performance>N</capture_transform_performance>
+    
<transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
+    
<transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
+    <pipeline_status>0</pipeline_status>
+    <parameters/>
+    <name>0014-check-lazy-empty-values</name>
+    <name_sync_with_filename>Y</name_sync_with_filename>
+    <description>Reads back the file 0014-write-lazy-empty-values wrote: the 
empty Number and Boolean cells
+      are empty.</description>
+    <extended_description/>
+    <created_user>-</created_user>
+    <modified_user>-</modified_user>
+    <created_date>2026/11/17 10:00:00.000</created_date>
+    <modified_date>2026/11/17 10:00:00.000</modified_date>
+    <created_hop_version/>
+    <modified_hop_version>2.21.0-SNAPSHOT</modified_hop_version>
+  </info>
+  <transform>
+    <name>Read back</name>
+    <type>ExcelInput</type>
+    <description/>
+    <distribute>Y</distribute>
+    <custom_distribution/>
+    <copies>1</copies>
+    <partitioning>
+      <method>none</method>
+      <schema_name/>
+    </partitioning>
+    <header>Y</header>
+    <noempty>Y</noempty>
+    <stoponempty>N</stoponempty>
+    <filefield/>
+    <sheetfield/>
+    <sheetrownumfield/>
+    <rownumfield/>
+    <sheetfield/>
+    <filefield/>
+    <limit>0</limit>
+    <encoding/>
+    <add_to_result_filenames>N</add_to_result_filenames>
+    <accept_filenames>N</accept_filenames>
+    <accept_field/>
+    <accept_transform_name/>
+    <file>
+      <name>${PROJECT_HOME}/output/excelwriter-lazy-empty.xlsx</name>
+      <filemask/>
+      <exclude_filemask/>
+      <file_required>Y</file_required>
+      <include_subfolders>N</include_subfolders>
+    </file>
+    <fields>
+      <field>
+        <name>name</name>
+        <type>String</type>
+        <length>-1</length>
+        <precision>-1</precision>
+        <trim_type>none</trim_type>
+        <repeat>N</repeat>
+        <format/>
+        <currency/>
+        <decimal/>
+        <group/>
+      </field>
+      <field>
+        <name>amount</name>
+        <type>Number</type>
+        <length>-1</length>
+        <precision>-1</precision>
+        <trim_type>none</trim_type>
+        <repeat>N</repeat>
+        <format/>
+        <currency/>
+        <decimal/>
+        <group/>
+      </field>
+      <field>
+        <name>flag</name>
+        <type>Boolean</type>
+        <length>-1</length>
+        <precision>-1</precision>
+        <trim_type>none</trim_type>
+        <repeat>N</repeat>
+        <format/>
+        <currency/>
+        <decimal/>
+        <group/>
+      </field>
+    </fields>
+    <sheets>
+      <sheet>
+        <name>Sheet1</name>
+        <startrow>0</startrow>
+        <startcol>0</startcol>
+      </sheet>
+    </sheets>
+    <strict_types>N</strict_types>
+    <error_ignored>N</error_ignored>
+    <error_line_skipped>N</error_line_skipped>
+    <bad_line_files_destination_directory/>
+    <bad_line_files_extension>warning</bad_line_files_extension>
+    <error_line_files_destination_directory/>
+    <error_line_files_extension>error</error_line_files_extension>
+    <line_number_files_destination_directory/>
+    <line_number_files_extension>line</line_number_files_extension>
+    <shortFileFieldName/>
+    <pathFieldName/>
+    <hiddenFieldName/>
+    <lastModificationTimeFieldName/>
+    <uriNameFieldName/>
+    <rootUriNameFieldName/>
+    <extensionFieldName/>
+    <sizeFieldName/>
+    <spreadsheet_type>SAX_POI</spreadsheet_type>
+    <attributes/>
+    <GUI>
+      <xloc>128</xloc>
+      <yloc>96</yloc>
+    </GUI>
+  </transform>
+  <transform>
+    <type>Dummy</type>
+    <name>verify</name>
+    <distribute>Y</distribute>
+    <copies>1</copies>
+    <GUI>
+      <xloc>320</xloc>
+      <yloc>96</yloc>
+    </GUI>
+    <description/>
+    <partitioning>
+      <method>none</method>
+      <schema_name/>
+    </partitioning>
+    <attributes/>
+  </transform>
+  <order>
+    <hop>
+      <from>Read back</from>
+      <to>verify</to>
+      <enabled>Y</enabled>
+    </hop>
+  </order>
+  <notepads/>
+  <attributes/>
+  <transform_error_handling/>
+</pipeline>
diff --git a/integration-tests/spreadsheet/0014-write-lazy-empty-values.hpl 
b/integration-tests/spreadsheet/0014-write-lazy-empty-values.hpl
new file mode 100644
index 0000000000..31959b14e6
--- /dev/null
+++ b/integration-tests/spreadsheet/0014-write-lazy-empty-values.hpl
@@ -0,0 +1,213 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<pipeline>
+  <info>
+    <pipeline_version/>
+    <capture_transform_performance>N</capture_transform_performance>
+    
<transform_performance_capturing_delay>1000</transform_performance_capturing_delay>
+    
<transform_performance_capturing_size_limit>100</transform_performance_capturing_size_limit>
+    <pipeline_status>0</pipeline_status>
+    <parameters/>
+    <name>0014-write-lazy-empty-values</name>
+    <name_sync_with_filename>Y</name_sync_with_filename>
+    <description>CSV file input with lazy conversion gives an empty Number and 
Boolean value as an empty byte
+      array. The Excel writer leaves those cells empty.</description>
+    <extended_description/>
+    <created_user>-</created_user>
+    <modified_user>-</modified_user>
+    <created_date>2026/11/17 10:00:00.000</created_date>
+    <modified_date>2026/11/17 10:00:00.000</modified_date>
+    <created_hop_version/>
+    <modified_hop_version>2.21.0-SNAPSHOT</modified_hop_version>
+  </info>
+  <transform>
+    <type>CSVInput</type>
+    <name>Lazy CSV</name>
+    <filename>${PROJECT_HOME}/files/excelwriter-lazy-empty.csv</filename>
+    <filename_field/>
+    <include_filename>N</include_filename>
+    <rownum_field/>
+    <header>Y</header>
+    <separator>,</separator>
+    <enclosure>"</enclosure>
+    <buffer_size>50000</buffer_size>
+    <lazy_conversion>Y</lazy_conversion>
+    <add_filename_result>N</add_filename_result>
+    <parallel>N</parallel>
+    <encoding>UTF-8</encoding>
+    <newline_possible>N</newline_possible>
+    <schemaDefinition/>
+    <ignoreFields>N</ignoreFields>
+    <namingScheme/>
+    <fields>
+      <field>
+        <name>name</name>
+        <length>-1</length>
+        <type>String</type>
+        <format/>
+        <trim_type>none</trim_type>
+        <precision>-1</precision>
+        <currency/>
+        <decimal>.</decimal>
+        <group/>
+      </field>
+      <field>
+        <name>amount</name>
+        <length>-1</length>
+        <type>Number</type>
+        <format>#.#</format>
+        <trim_type>none</trim_type>
+        <precision>-1</precision>
+        <currency/>
+        <decimal>.</decimal>
+        <group/>
+      </field>
+      <field>
+        <name>flag</name>
+        <length>-1</length>
+        <type>Boolean</type>
+        <format/>
+        <trim_type>none</trim_type>
+        <precision>-1</precision>
+        <currency/>
+        <decimal>.</decimal>
+        <group/>
+      </field>
+    </fields>
+    <distribute>Y</distribute>
+    <copies>1</copies>
+    <GUI>
+      <xloc>128</xloc>
+      <yloc>96</yloc>
+    </GUI>
+    <description/>
+    <partitioning>
+      <method>none</method>
+      <schema_name/>
+    </partitioning>
+    <attributes/>
+  </transform>
+  <transform>
+    <name>Microsoft Excel writer</name>
+    <type>TypeExitExcelWriterTransform</type>
+    <description/>
+    <distribute>Y</distribute>
+    <custom_distribution/>
+    <copies>1</copies>
+    <partitioning>
+      <method>none</method>
+      <schema_name/>
+    </partitioning>
+    <add_to_result_filenames>N</add_to_result_filenames>
+    <appendEmpty>0</appendEmpty>
+    <appendLines>N</appendLines>
+    <appendOffset>0</appendOffset>
+    <appendOmitHeader>N</appendOmitHeader>
+    <file>
+      <autosizecolums>N</autosizecolums>
+      <createParentFolder>Y</createParentFolder>
+      <add_date>N</add_date>
+      <date_time_format/>
+      <do_not_open_newfile_init>N</do_not_open_newfile_init>
+      <extension>xlsx</extension>
+      <name>${PROJECT_HOME}/output/excelwriter-lazy-empty</name>
+      <filename_field/>
+      <filename_in_field>N</filename_in_field>
+      <if_file_exists>new</if_file_exists>
+      <if_sheet_exists>new</if_sheet_exists>
+      <password>Encrypted </password>
+      <protected_by/>
+      <protect_sheet>N</protect_sheet>
+      <sheetname>Sheet1</sheetname>
+      <SpecifyFormat>N</SpecifyFormat>
+      <splitevery>0</splitevery>
+      <stream_data>N</stream_data>
+      <add_time>N</add_time>
+      <split>N</split>
+    </file>
+    <footer>N</footer>
+    <forceFormulaRecalculation>N</forceFormulaRecalculation>
+    <header>Y</header>
+    <leaveExistingStylesUnchanged>N</leaveExistingStylesUnchanged>
+    <makeSheetActive>Y</makeSheetActive>
+    <fields>
+      <field>
+        <commentAuthorField/>
+        <commentField/>
+        <format/>
+        <formula>N</formula>
+        <hyperlinkField/>
+        <name>name</name>
+        <styleCell/>
+        <title>name</title>
+        <titleStyleCell/>
+        <type>String</type>
+      </field>
+      <field>
+        <commentAuthorField/>
+        <commentField/>
+        <format/>
+        <formula>N</formula>
+        <hyperlinkField/>
+        <name>amount</name>
+        <styleCell/>
+        <title>amount</title>
+        <titleStyleCell/>
+        <type>Number</type>
+      </field>
+      <field>
+        <commentAuthorField/>
+        <commentField/>
+        <format/>
+        <formula>N</formula>
+        <hyperlinkField/>
+        <name>flag</name>
+        <styleCell/>
+        <title>flag</title>
+        <titleStyleCell/>
+        <type>Boolean</type>
+      </field>
+    </fields>
+    <rowWritingMethod>overwrite</rowWritingMethod>
+    <startingCell>A1</startingCell>
+    <template>
+      <enabled>N</enabled>
+      <filename>template.xls</filename>
+      <sheet_enabled>N</sheet_enabled>
+      <hidden>N</hidden>
+      <sheetname/>
+    </template>
+    <attributes/>
+    <GUI>
+      <xloc>320</xloc>
+      <yloc>96</yloc>
+    </GUI>
+  </transform>
+  <order>
+    <hop>
+      <from>Lazy CSV</from>
+      <to>Microsoft Excel writer</to>
+      <enabled>Y</enabled>
+    </hop>
+  </order>
+  <notepads/>
+  <attributes/>
+  <transform_error_handling/>
+</pipeline>
diff --git 
a/integration-tests/spreadsheet/datasets/golden-excelwriter-lazy-empty.csv 
b/integration-tests/spreadsheet/datasets/golden-excelwriter-lazy-empty.csv
new file mode 100644
index 0000000000..5374dde05f
--- /dev/null
+++ b/integration-tests/spreadsheet/datasets/golden-excelwriter-lazy-empty.csv
@@ -0,0 +1,3 @@
+name,amount,flag
+empty,,
+full,1.5,true
diff --git a/integration-tests/spreadsheet/files/excelwriter-lazy-empty.csv 
b/integration-tests/spreadsheet/files/excelwriter-lazy-empty.csv
new file mode 100644
index 0000000000..341fb37938
--- /dev/null
+++ b/integration-tests/spreadsheet/files/excelwriter-lazy-empty.csv
@@ -0,0 +1,3 @@
+name,amount,flag
+full,1.5,Y
+empty,,
diff --git a/integration-tests/spreadsheet/main-0014-excelwriter-lazy-empty.hwf 
b/integration-tests/spreadsheet/main-0014-excelwriter-lazy-empty.hwf
new file mode 100644
index 0000000000..a72befc34d
--- /dev/null
+++ b/integration-tests/spreadsheet/main-0014-excelwriter-lazy-empty.hwf
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+-->
+<workflow>
+  <name>main-0014-excelwriter-lazy-empty</name>
+  <name_sync_with_filename>Y</name_sync_with_filename>
+  <description/>
+  <extended_description/>
+  <workflow_version/>
+  <created_user>-</created_user>
+  <created_date>2021/01/05 13:04:10.956</created_date>
+  <modified_user>-</modified_user>
+  <modified_date>2021/01/05 13:04:10.956</modified_date>
+  <parameters>
+    </parameters>
+  <actions>
+    <action>
+      <name>Start</name>
+      <description/>
+      <type>SPECIAL</type>
+      <attributes/>
+      <repeat>N</repeat>
+      <schedulerType>0</schedulerType>
+      <intervalSeconds>0</intervalSeconds>
+      <intervalMinutes>60</intervalMinutes>
+      <hour>12</hour>
+      <minutes>0</minutes>
+      <weekDay>1</weekDay>
+      <DayOfMonth>1</DayOfMonth>
+      <parallel>N</parallel>
+      <xloc>50</xloc>
+      <yloc>50</yloc>
+      <attributes_hac/>
+    </action>
+    <action>
+      <name>0014-write-lazy-empty-values.hpl</name>
+      <description/>
+      <type>PIPELINE</type>
+      <attributes/>
+      <filename>${PROJECT_HOME}/0014-write-lazy-empty-values.hpl</filename>
+      <params_from_previous>N</params_from_previous>
+      <exec_per_row>N</exec_per_row>
+      <clear_rows>N</clear_rows>
+      <clear_files>N</clear_files>
+      <set_logfile>N</set_logfile>
+      <logfile/>
+      <logext/>
+      <add_date>N</add_date>
+      <add_time>N</add_time>
+      <loglevel>Basic</loglevel>
+      <set_append_logfile>N</set_append_logfile>
+      <wait_until_finished>Y</wait_until_finished>
+      <create_parent_folder>N</create_parent_folder>
+      <run_configuration>local</run_configuration>
+      <parameters>
+        <pass_all_parameters>Y</pass_all_parameters>
+      </parameters>
+      <parallel>N</parallel>
+      <xloc>171</xloc>
+      <yloc>50</yloc>
+      <attributes_hac/>
+    </action>
+    <action>
+      <name>Run Pipeline Unit Tests</name>
+      <description/>
+      <type>RunPipelineTests</type>
+      <attributes/>
+      <test_names>
+        <test_name>
+          <name>0014-check-lazy-empty-values UNIT</name>
+        </test_name>
+      </test_names>
+      <parallel>N</parallel>
+      <xloc>384</xloc>
+      <yloc>48</yloc>
+      <attributes_hac/>
+    </action>
+  </actions>
+  <hops>
+    <hop>
+      <from>Start</from>
+      <to>0014-write-lazy-empty-values.hpl</to>
+      <enabled>Y</enabled>
+      <evaluation>Y</evaluation>
+      <unconditional>Y</unconditional>
+    </hop>
+    <hop>
+      <from>0014-write-lazy-empty-values.hpl</from>
+      <to>Run Pipeline Unit Tests</to>
+      <enabled>Y</enabled>
+      <evaluation>Y</evaluation>
+      <unconditional>N</unconditional>
+    </hop>
+  </hops>
+  <notepads>
+  </notepads>
+  <attributes/>
+</workflow>
diff --git 
a/integration-tests/spreadsheet/metadata/dataset/golden-excelwriter-lazy-empty.json
 
b/integration-tests/spreadsheet/metadata/dataset/golden-excelwriter-lazy-empty.json
new file mode 100644
index 0000000000..34e1bd83b5
--- /dev/null
+++ 
b/integration-tests/spreadsheet/metadata/dataset/golden-excelwriter-lazy-empty.json
@@ -0,0 +1,32 @@
+{
+  "base_filename": "golden-excelwriter-lazy-empty.csv",
+  "name": "golden-excelwriter-lazy-empty",
+  "description": "",
+  "dataset_fields": [
+    {
+      "field_comment": "",
+      "field_length": -1,
+      "field_type": 2,
+      "field_precision": -1,
+      "field_format": "",
+      "field_name": "name"
+    },
+    {
+      "field_comment": "",
+      "field_length": -1,
+      "field_type": 1,
+      "field_precision": -1,
+      "field_format": "",
+      "field_name": "amount"
+    },
+    {
+      "field_comment": "",
+      "field_length": -1,
+      "field_type": 4,
+      "field_precision": -1,
+      "field_format": "",
+      "field_name": "flag"
+    }
+  ],
+  "folder_name": "${HOP_DATASETS_FOLDER}"
+}
diff --git 
a/integration-tests/spreadsheet/metadata/unit-test/0014-check-lazy-empty-values 
UNIT.json 
b/integration-tests/spreadsheet/metadata/unit-test/0014-check-lazy-empty-values 
UNIT.json
new file mode 100644
index 0000000000..1f2300d102
--- /dev/null
+++ 
b/integration-tests/spreadsheet/metadata/unit-test/0014-check-lazy-empty-values 
UNIT.json   
@@ -0,0 +1,36 @@
+{
+  "variableValues": [],
+  "database_replacements": [],
+  "autoOpening": true,
+  "basePath": "",
+  "golden_data_sets": [
+    {
+      "field_mappings": [
+        {
+          "transform_field": "name",
+          "data_set_field": "name"
+        },
+        {
+          "transform_field": "amount",
+          "data_set_field": "amount"
+        },
+        {
+          "transform_field": "flag",
+          "data_set_field": "flag"
+        }
+      ],
+      "field_order": [
+        "name"
+      ],
+      "transform_name": "verify",
+      "data_set_name": "golden-excelwriter-lazy-empty"
+    }
+  ],
+  "input_data_sets": [],
+  "name": "0014-check-lazy-empty-values UNIT",
+  "description": "",
+  "trans_test_tweaks": [],
+  "persist_filename": "",
+  "pipeline_filename": "./0014-check-lazy-empty-values.hpl",
+  "test_type": "UNIT_TEST"
+}
diff --git 
a/plugins/transforms/excel/src/main/java/org/apache/hop/pipeline/transforms/excelwriter/ExcelWriterTransform.java
 
b/plugins/transforms/excel/src/main/java/org/apache/hop/pipeline/transforms/excelwriter/ExcelWriterTransform.java
index 7d0c120ac2..bfb28c70a7 100644
--- 
a/plugins/transforms/excel/src/main/java/org/apache/hop/pipeline/transforms/excelwriter/ExcelWriterTransform.java
+++ 
b/plugins/transforms/excel/src/main/java/org/apache/hop/pipeline/transforms/excelwriter/ExcelWriterTransform.java
@@ -710,13 +710,16 @@ public class ExcelWriterTransform
             }
             break;
           case IValueMeta.TYPE_BOOLEAN:
-            if (v != null) {
-              cell.setCellValue(vMeta.getBoolean(v));
+            // A lazily converted empty value is not null but converts to 
null: no cell value
+            Boolean bool = v != null ? vMeta.getBoolean(v) : null;
+            if (bool != null) {
+              cell.setCellValue(bool);
             }
             break;
           case IValueMeta.TYPE_BIGNUMBER, IValueMeta.TYPE_NUMBER, 
IValueMeta.TYPE_INTEGER:
-            if (v != null) {
-              cell.setCellValue(vMeta.getNumber(v));
+            Double number = v != null ? vMeta.getNumber(v) : null;
+            if (number != null) {
+              cell.setCellValue(number);
             }
             break;
           default:
diff --git 
a/plugins/transforms/excel/src/test/java/org/apache/hop/pipeline/transforms/excelwriter/ExcelWriterTransformTest.java
 
b/plugins/transforms/excel/src/test/java/org/apache/hop/pipeline/transforms/excelwriter/ExcelWriterTransformTest.java
index 1439f2041d..ef4b89e4b8 100644
--- 
a/plugins/transforms/excel/src/test/java/org/apache/hop/pipeline/transforms/excelwriter/ExcelWriterTransformTest.java
+++ 
b/plugins/transforms/excel/src/test/java/org/apache/hop/pipeline/transforms/excelwriter/ExcelWriterTransformTest.java
@@ -47,6 +47,7 @@ import org.apache.hop.core.row.IRowMeta;
 import org.apache.hop.core.row.IValueMeta;
 import org.apache.hop.core.row.value.ValueMetaBigNumber;
 import org.apache.hop.core.row.value.ValueMetaBinary;
+import org.apache.hop.core.row.value.ValueMetaBoolean;
 import org.apache.hop.core.row.value.ValueMetaDate;
 import org.apache.hop.core.row.value.ValueMetaInteger;
 import org.apache.hop.core.row.value.ValueMetaInternetAddress;
@@ -57,6 +58,8 @@ import 
org.apache.hop.pipeline.transforms.mock.TransformMockHelper;
 import org.apache.hop.utils.TestUtils;
 import org.apache.poi.hssf.usermodel.HSSFSheet;
 import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellType;
 import org.apache.poi.ss.usermodel.Row;
 import org.apache.poi.ss.usermodel.Sheet;
 import org.apache.poi.ss.usermodel.Workbook;
@@ -402,6 +405,34 @@ class ExcelWriterTransformTest {
     testBaseXlsx(vmi, vObj, false, false);
   }
 
+  /**
+   * After a CSV file input with lazy conversion, an empty field is an empty 
byte array: not null,
+   * but it converts to null. The cell stays empty.
+   */
+  @Test
+  void testValueNumberEmptyAndLazilyConverted() throws Exception {
+    testBaseXlsx(lazilyConverted(new ValueMetaNumber("value_number")), new 
byte[0], false, false);
+    assertBlankCell();
+  }
+
+  @Test
+  void testValueBooleanEmptyAndLazilyConverted() throws Exception {
+    testBaseXlsx(lazilyConverted(new ValueMetaBoolean("value_bool")), new 
byte[0], false, false);
+    assertBlankCell();
+  }
+
+  private static IValueMeta lazilyConverted(IValueMeta valueMeta) {
+    // As CSV file input reads it: the text of the file, converted when needed
+    valueMeta.setStorageType(IValueMeta.STORAGE_TYPE_BINARY_STRING);
+    valueMeta.setStorageMetadata(new ValueMetaString(valueMeta.getName()));
+    return valueMeta;
+  }
+
+  private void assertBlankCell() {
+    Cell cell = 
dataMock.currentWorkbookDefinition.getSheet().getRow(1).getCell(0);
+    assertTrue(cell == null || cell.getCellType() == CellType.BLANK, 
String.valueOf(cell));
+  }
+
   @Test
   void testValueDate() throws Exception {
 

Reply via email to