It isn't a graphic it's a text box but the content is still editable as text.

If not, can you post the workbook.xls file.

On 12/10/2010 3:45 PM, Risken wrote:
Why is it that the generated xlsx file containing 2 images and one textbox
gives such strange result when I try dragging the images/textbox around in
xl?

The same file works perfectly well in OpenOffice.
I also tried changing to HSSF and .xls and the file worked perfect then, but
I would much rather generate .xlsx files...

Is it faulty coding by me or is XL having hickups?

In XL when draggin one image and releasing it the two images change places.
And if I stretch the textbox it becomes an Image!

Please help me out here!!?

/Johan

import java.io.*;
import org.apache.poi.xssf.usermodel.*;


public class ImageTest {

     public static void main(String[] args) throws Exception{
         FileInputStream is;
         File file;
         byte[] bytes;
         int idx;

         XSSFWorkbook wb = new XSSFWorkbook();
         XSSFSheet sh = wb.createSheet();
         XSSFDrawing p = sh.createDrawingPatriarch();

         file = new File("c:\\img.jpg");
         bytes = new byte[(int)file.length()];
         is = new FileInputStream(file);
         is.read(bytes);
         is.close();

         idx = wb.addPicture(bytes, XSSFWorkbook.PICTURE_TYPE_JPEG);
         p.createPicture(new XSSFClientAnchor(0, 0, 0, 0, (short)1, 1,
(short)4, 10),idx);

         file = new File("c:\\img2.jpg");
         bytes = new byte[(int)file.length()];
         is = new FileInputStream(file);
         is.read(bytes);
         is.close();

         idx = wb.addPicture(bytes, XSSFWorkbook.PICTURE_TYPE_JPEG);
         p.createPicture(new XSSFClientAnchor(0, 0, 0, 0, (short)1, 12,
(short)4, 30),idx);


         XSSFTextBox textbox1 = p.createTextbox(
         new XSSFClientAnchor(0,0,0,0,(short)9,1,(short)11,2));

         textbox1.setLineStyleColor(255, 0, 0);
         textbox1.setText(new XSSFRichTextString("Testing") );


         FileOutputStream out = new FileOutputStream("c:\\workbook.xlsx");
         wb.write(out);
         out.close();
     }

}




---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to