Hi. I made one xlsx file with some cells selected and saved. After that I
loded with poi and
 if you call this code

InputStream myxls = new FileInputStream("ex1.xlsx");
XSSFWorkbook wb     = new XSSFWorkbook(myxls);  
XSSFSheet s = wb.getSheetAt( 0);
XSSFRow r = s.getRow(0);
CTRowImpl cr = (CTRowImpl) r.getCTRow();

the content of cr is

<xml-fragment r="1" spans="1:3" x14ac:dyDescent="0.25"
xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships";
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006";
xmlns:x14ac="http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac";
xmlns:main="http://schemas.openxmlformats.org/spreadsheetml/2006/main";>
  <main:c r="A1" s="1" t="s">
    <main:v>0</main:v>
  </main:c>
  <main:c r="B1" s="1"/>
  <main:c r="C1" s="1"/>
</xml-fragment>

You can see in the first row attribute spans="1:3"

Also if you call cr.getSpans() you will get the list of spans, in my case
1:3. But I am unable to edit this list. There is a method setSpans and it
requires a parameter of type XMLSimpleList but I am unable to add values to
this list.

Probably it is possible to somehow edit this values from java but it seams
to be rocket science.

I am waiting for some replay regarding this issue.

Cristian

MSB wrote:
> 
> Well, there is an option to center - no, pre Webster so it ought to be
> centre - the cells contents across a selection in the CellStyle class just
> as there is in Excel, but like you, I cannot see how to obviously make use
> of it. Currently, I am thinking about trying to use the ability to create
> a name to see if that will help but I cannot be sure.
> 
> Do you know in advance which cells need to be treated in this way? If so,
> you could create a template that POI would then be able to open and
> populate with data. Secondly, if you do know which cells are to be treated
> in this way, you could create styles on another sheet in the workbook and
> then try applying them to other cells in another sheet of the same
> workbook. Again, I do not know if this would work but it should be quick
> enough and easy enough to try out.
> 
> When I get back homw after work today, I will have a play to see what I
> can come up with.
> 
> Yours
> 
> Mark B
> 
> 
> Cristian Petrula wrote:
>> 
>> Hi. I have a huge problem. I need to use ALIGN_CENTER_SELECTION over 2,
>> 3..
>> cells but I am not allowed to merge cells And I don't have any idea how
>> to
>> simulate cell selection. I saw in xml file attribute "spans" in row
>> element.
>> Do you know how to use this align style with selected cells?
>> 
>> Cristian
>> 
>> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/ALIGN_CENTER_SELECTION-question-tp28660795p28667389.html
Sent from the POI - User mailing list archive at Nabble.com.


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

Reply via email to