Hi, Hm, sorry, but I don't see that much gain by adding that method in POI itself, in almost all cases people will know which type of cell they are adding, especially as you usually style columns differently depending on the type. It can also become a performance problem with the number of instanceof-calls that you do here.
For now I think it better if you put that method into a helper class in your code so you can use it. Dominik. On Tue, Sep 1, 2015 at 4:02 PM, Mohamed Ennahdi El Idrissi <[email protected]> wrote: > Hi Dominik, > > I attached the .java files hereby. > > I wanted to commit changes on SVN, but I am not allowed to. > > The changes are very minor. a setCellValue() method with an Object argument. > > > From: Dominik Stadler <[email protected]> > To: POI Users List <[email protected]> > Sent: Tuesday, September 1, 2015 1:17 PM > Subject: Re: Java Dynamic Casting in Apache POI > > Hi, > > I think you missed to attach the actual changed classes that you refer > to, additionally a diff/patch file would be easier to look at as it > will show what are the actual changes that you propose... > > Dominik. > > On Tue, Sep 1, 2015 at 1:01 PM, Nick Burch <[email protected]> wrote: >> On Mon, 31 Aug 2015, Mohamed Ennahdi El Idrissi wrote: >>> >>> I have been using Apache POI, and I faced a situation where I could use >>> reflection to determine which datatype a cell should have based on the >>> datatype of the value that is going to contain in Excel. >> >> >> For reading, the normal way to do that is to fetch the cell's type, and >> read >> the value based on that. Or, use DataFormatter to give you back a string >> representation >> >> For writing, POI accepts both objects and primatives. If you're writing >> something like a number, writing just the number isn't normally enough, >> you >> normally also need to apply cell formatting rules to format the cell's >> contents. >> >>> When I tried to use, for instance, anObject.getClass().cast(), the POI >>> library would show an error at compile time, while this code is certainly >>> valid at runtime. >> >> >> What are you trying to cast to what? >> >> Nick >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [email protected] >> For additional commands, e-mail: [email protected] > > > >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > > > --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
