You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Andreas Reichel <an...@manticore-projects.com> on 2021/12/14 07:18:50 UTC

Write NULL to cells, why not use setValue()?

Compliments of the season,

please allow me to ask: why exactly does the Cell interface define

setValue(double value)

instead of

setValue(Double value)

which would allow for setting NULL values?

I understand, that I am supposed to use setBlank() instead but when you
create very large Excel file pragmatically, then it is very cumbersome
to check every single Value for NULL first in order to setValue() or
setBlank().
Was there a chance to change/amend setValue() to use Objects instead of
primitives only? (I would volunteer with a PR of course).

Warm regards
Andreas


Re: Write NULL to cells, why not use setValue()?

Posted by PJ Fanning <fa...@yahoo.com.INVALID>.
Have a look at the Cell class and there are some default methods on it. The advantage of this is all the implementations of Cell inherit them. You're free to experiment and submit a patch. We can't change the param types, return types or names of existing methods - but we could look at adding more methods.






On Tuesday 14 December 2021, 11:23:58 GMT+1, Andreas Reichel <an...@manticore-projects.com> wrote: 





Ok, got it.

Thank you for the explanation, all the best

Andreas

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Write NULL to cells, why not use setValue()?

Posted by Andreas Reichel <an...@manticore-projects.com>.
Ok, got it.

Thank you for the explanation, all the best
Andreas

Re: Write NULL to cells, why not use setValue()?

Posted by PJ Fanning <fa...@yahoo.com.INVALID>.
It is a binary incompatible change. Code compiled against an older version of POI will not be guaranteed to run on a newer version of POI.
While we can't guarantee full binary compatibility across all releases, I would argue strongly against breaking binary compatibility for this.
This is a very old API method and people have been happy with it until now and removing it to suit 1 user is not a good idea in my opinion.






On Tuesday 14 December 2021, 10:24:42 GMT+1, Andreas Reichel <an...@manticore-projects.com> wrote: 





Thanks for the prompt feedback.

Question: Why would we need to depreciate setValue(double value)
instead of replacing it immediately with setValue(Double value)?
As far as I understand, the JVM boxes/unboxes the primitives
automatically?

Of course, if this change was not welcome, I would need to implement
helper methods by myself. But maybe 1000 other users right now write
exactly the same helper methods within their own projects?

Long story short: please discuss it internally and hand a final
decision. If a PR was welcome I would provide it, otherwise I would
fall back to my own helper methods.

Again, thank you for your time and advise.
Cheers

Andreas

On Tue, 2021-12-14 at 09:09 +0000, PJ Fanning wrote:
> Hi Andreas,
> We can't remove APIs without deprecating them for a release cycle
> first.
> 
> So the only solution is the add more API methods.
> 
> If we add a new setDoubleObject method, we would need to add
> setBooleanObject, etc to keep the API consistent.
> 
> I would not favour the change you are proposing generally. While the
> API is not to your liking, adding a whole extra set of null friendly
> sets (and possibly gets) would make the API even larger and for me,
> the benefit is not great enough. Other devs might have different
> opinions on this.
> 
> Developers can also add their own helper methods to do this sort of
> thing.
> 
> 
> public static void setCellValue(Cell c, Double d) {
>   if (d == null) {
>     cell.setBlank();
>   } else {
>     cell.setValue(d);
>   }
> }
> 
> 
> 
> 
> 
> 
> On Tuesday 14 December 2021, 08:19:07 GMT+1, Andreas Reichel
> <an...@manticore-projects.com> wrote: 
> 
> 
> 
> 
> 
> Compliments of the season,
> 
> please allow me to ask: why exactly does the Cell interface define
> 
> setValue(double value)
> 
> instead of
> 
> setValue(Double value)
> 
> which would allow for setting NULL values?
> 
> I understand, that I am supposed to use setBlank() instead but when
> you
> create very large Excel file pragmatically, then it is very
> cumbersome
> to check every single Value for NULL first in order to setValue() or
> setBlank().
> Was there a chance to change/amend setValue() to use Objects instead
> of
> primitives only? (I would volunteer with a PR of course).
> 
> Warm regards
> Andreas

> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org

> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Write NULL to cells, why not use setValue()?

Posted by Andreas Reichel <an...@manticore-projects.com>.
Thanks for the prompt feedback.

Question: Why would we need to depreciate setValue(double value)
instead of replacing it immediately with setValue(Double value)?
As far as I understand, the JVM boxes/unboxes the primitives
automatically?

Of course, if this change was not welcome, I would need to implement
helper methods by myself. But maybe 1000 other users right now write
exactly the same helper methods within their own projects?

Long story short: please discuss it internally and hand a final
decision. If a PR was welcome I would provide it, otherwise I would
fall back to my own helper methods.

Again, thank you for your time and advise.
Cheers

Andreas

On Tue, 2021-12-14 at 09:09 +0000, PJ Fanning wrote:
> Hi Andreas,
> We can't remove APIs without deprecating them for a release cycle
> first.
> 
> So the only solution is the add more API methods.
> 
> If we add a new setDoubleObject method, we would need to add
> setBooleanObject, etc to keep the API consistent.
> 
> I would not favour the change you are proposing generally. While the
> API is not to your liking, adding a whole extra set of null friendly
> sets (and possibly gets) would make the API even larger and for me,
> the benefit is not great enough. Other devs might have different
> opinions on this.
> 
> Developers can also add their own helper methods to do this sort of
> thing.
> 
> 
> public static void setCellValue(Cell c, Double d) {
>   if (d == null) {
>     cell.setBlank();
>   } else {
>     cell.setValue(d);
>   }
> }
> 
> 
> 
> 
> 
> 
> On Tuesday 14 December 2021, 08:19:07 GMT+1, Andreas Reichel
> <an...@manticore-projects.com> wrote: 
> 
> 
> 
> 
> 
> Compliments of the season,
> 
> please allow me to ask: why exactly does the Cell interface define
> 
> setValue(double value)
> 
> instead of
> 
> setValue(Double value)
> 
> which would allow for setting NULL values?
> 
> I understand, that I am supposed to use setBlank() instead but when
> you
> create very large Excel file pragmatically, then it is very
> cumbersome
> to check every single Value for NULL first in order to setValue() or
> setBlank().
> Was there a chance to change/amend setValue() to use Objects instead
> of
> primitives only? (I would volunteer with a PR of course).
> 
> Warm regards
> Andreas
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
> 


Re: Write NULL to cells, why not use setValue()?

Posted by PJ Fanning <fa...@yahoo.com.INVALID>.
Hi Andreas,
We can't remove APIs without deprecating them for a release cycle first.

So the only solution is the add more API methods.

If we add a new setDoubleObject method, we would need to add setBooleanObject, etc to keep the API consistent.

I would not favour the change you are proposing generally. While the API is not to your liking, adding a whole extra set of null friendly sets (and possibly gets) would make the API even larger and for me, the benefit is not great enough. Other devs might have different opinions on this.

Developers can also add their own helper methods to do this sort of thing.


public static void setCellValue(Cell c, Double d) {
  if (d == null) {
    cell.setBlank();
  } else {
    cell.setValue(d);
  }
}






On Tuesday 14 December 2021, 08:19:07 GMT+1, Andreas Reichel <an...@manticore-projects.com> wrote: 





Compliments of the season,

please allow me to ask: why exactly does the Cell interface define

setValue(double value)

instead of

setValue(Double value)

which would allow for setting NULL values?

I understand, that I am supposed to use setBlank() instead but when you
create very large Excel file pragmatically, then it is very cumbersome
to check every single Value for NULL first in order to setValue() or
setBlank().
Was there a chance to change/amend setValue() to use Objects instead of
primitives only? (I would volunteer with a PR of course).

Warm regards
Andreas


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org