Return-Path: X-Original-To: apmail-poi-user-archive@www.apache.org Delivered-To: apmail-poi-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 640EC17F44 for ; Thu, 5 Feb 2015 20:22:50 +0000 (UTC) Received: (qmail 88340 invoked by uid 500); 5 Feb 2015 20:22:50 -0000 Delivered-To: apmail-poi-user-archive@poi.apache.org Received: (qmail 88310 invoked by uid 500); 5 Feb 2015 20:22:49 -0000 Mailing-List: contact user-help@poi.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "POI Users List" Delivered-To: mailing list user@poi.apache.org Received: (qmail 88298 invoked by uid 99); 5 Feb 2015 20:22:49 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Feb 2015 20:22:49 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of dominik.stadler@gmx.at designates 212.227.15.15 as permitted sender) Received: from [212.227.15.15] (HELO mout.gmx.net) (212.227.15.15) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Feb 2015 20:22:23 +0000 Received: from mail-pa0-f53.google.com ([209.85.220.53]) by mail.gmx.com (mrgmx002) with ESMTPSA (Nemesis) id 0MAgvb-1YTgbC45gB-00BxPR for ; Thu, 05 Feb 2015 21:22:02 +0100 Received: by mail-pa0-f53.google.com with SMTP id lf10so4620881pab.12 for ; Thu, 05 Feb 2015 12:22:00 -0800 (PST) MIME-Version: 1.0 X-Received: by 10.66.138.72 with SMTP id qo8mr8782658pab.84.1423167720333; Thu, 05 Feb 2015 12:22:00 -0800 (PST) Received: by 10.70.118.1 with HTTP; Thu, 5 Feb 2015 12:22:00 -0800 (PST) In-Reply-To: References: Date: Thu, 5 Feb 2015 21:22:00 +0100 Message-ID: Subject: Re: How do control font and autoSizeColumn in XSSF? From: Dominik Stadler To: POI Users List Content-Type: text/plain; charset=UTF-8 X-Provags-ID: V03:K0:KbXnp4JiJfv1vHqrADGc0eqM75kXqi1W83pIt4U0lg7KPu4h9uS MjckjxSFP0PMszsRte6P/0Rg/aK3lkR+65XCWHWpvFUgWQP2s0bWnR64fVWTNPvrkXmBVPC Pxgec1DcvWi+aHRg1VHRmDv+aJjOSG8ozBnY1VnkwF4T6C9AOpw6EuDVNaKpARXOj2/iU+t oNCxaIKcHQi3lW9aGyQYQ== X-UI-Out-Filterresults: notjunk:1; X-Virus-Checked: Checked by ClamAV on apache.org Hmm, they should behave very similar, only if you run it on different machines there might be differences due to the number of fonts found on the machine. Does one break if you leave out the other, i.e. without setting the Font, does autosize work and vice versa? Can you pack that up into a self-contained unit test and report it at https://issues.apache.org/bugzilla/ Dominik. On Thu, Feb 5, 2015 at 4:52 PM, Larry Wilson wrote: > I've recently had to change from an HSSF workbook to an XSSF for password support. Some methods don't appear to work in XSSF that worked fine in HSSF. I've checked the online documents and it looks like all this should work. > > Significant code snippets pulled from our source (we're using enums with int columnNumber String columnName for columns): > > import org.apache.poi.poifs.crypt.EncryptionInfo; > import org.apache.poi.poifs.crypt.EncryptionMode; > import org.apache.poi.poifs.crypt.Encryptor; > import org.apache.poi.poifs.filesystem.POIFSFileSystem; > import org.apache.poi.ss.usermodel.Cell; > import org.apache.poi.ss.usermodel.CellStyle; > import org.apache.poi.ss.usermodel.ClientAnchor; > import org.apache.poi.ss.usermodel.CreationHelper; > import org.apache.poi.ss.usermodel.Drawing; > import org.apache.poi.ss.usermodel.Font; > import org.apache.poi.ss.usermodel.IndexedColors; > import org.apache.poi.ss.usermodel.Picture; > import org.apache.poi.ss.usermodel.PrintSetup; > import org.apache.poi.ss.usermodel.Row; > import org.apache.poi.ss.usermodel.Sheet; > import org.apache.poi.ss.usermodel.Workbook; > import org.apache.poi.ss.util.CellRangeAddress; > import org.apache.poi.util.IOUtils; > import org.apache.poi.xssf.usermodel.XSSFWorkbook; > ... > Map styles = new HashMap(); > Font rowFont = wb.createFont(); > rowFont.setFontName("Arial"); > ... > CellStyle style = createBorderedStyle(wb); > style.setAlignment(CellStyle.ALIGN_LEFT); > style.setVerticalAlignment(CellStyle.VERTICAL_TOP); > style.setWrapText(true); > style.setFont(rowFont); > styles.put("cell", style); > ... > Workbook wb = new XSSFWorkbook(); > ... > Sheet sheet = wb.createSheet("test"); > ... > Row headerRow = setSheetPropertiesAndReturnHeaderRow(wb, sheet, styles, ClientColumn.values().length); > > // Cell headerCell; > for (ClientColumn column : ClientColumn.values()) { > createCell(headerRow, column.columnNumber, column.columnName, styles); > } > > Row row = sheet.createRow(headerRow.getRowNum() + 1); > > for (ClientColumn column : ClientColumn.values()) { > Cell cell = row.createCell(column.columnNumber); > cell.setCellStyle(styles.get("cell")); > .... > } > > // Adjust columns widths to fit using ClientColumn enum > for (ClientColumn column : ClientColumn.values()) { > sheet.autoSizeColumn(column.columnNumber); // also tried sheet.autoSizeColumn((short)column.columnNumber); > } > ... > > When the spreadsheet is viewed, the font is not set, and the columns have not been autosized when using XSSF. When using HSSF, it works fine. > > What am I missing? > > Thanks > > > --------------------------------------------------------------------- > 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