You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by "Schene, Chris" <Ch...@experian.com> on 2016/01/19 17:06:22 UTC
How do I left Align a cell?
Hi,
I am using this code to create a cell that I want left justified but it is
showing up as centered
private CellStyle createCellString(XSSFWorkbook wb, int c) {
CellStyle myCellStyleStyle= wb.createCellStyle();
XSSFFont myFont= wb.createFont();
myFont.setFontHeightInPoints((short)10);
myFont.setFontName("Arial");
//System.out.println("createCellString color = " + c + "(" +
getColorName(c) + ")");
myFont.setColor((short) c);
myFont.setBold(c == getColorIndex("BLACK") ? false : true);
myFont.setItalic(false);
myCellStyleStyle.setFont(myFont);
myCellStyleStyle.setAlignment((short) ALIGN_LEFT);
myCellStyleStyle.setVerticalAlignment(valign);
return myCellStyleStyle;
}
Christopher Schene
Field Engineer
Global
Fraud and Identity Solutions
Experian
16260 N. 71st Street
Suite #400 ?Scottsdale
Arizona, USA
85254
+1 602.290.9792 mobile
+1 480.751.3928 office
chris.schene@experian.com
www.experian.com <http://www.experian.com/>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org
Re: How do I left Align a cell?
Posted by Javen O'Neal <ja...@gmail.com>.
See
https://poi.apache.org/apidocs/org/apache/poi/ss/util/CellUtil.html#setCellStyleProperty(org.apache.poi.ss.usermodel.Cell,%20org.apache.poi.ss.usermodel.Workbook,%20java.lang.String,%20java.lang.Object)
On Jan 19, 2016 8:19 AM, "Javen O'Neal" <ja...@gmail.com> wrote:
> Make sure you call cell.setCellStyle(myCellStyle) when you're doing. You
> may want to use CellUtil.setStyleProperties to avoid creating duplicate
> styles or modifying the styles of other cells that share the same style.
> On Jan 19, 2016 08:06, "Schene, Chris" <Ch...@experian.com> wrote:
>
>> Hi,
>>
>> I am using this code to create a cell that I want left justified but it is
>> showing up as centered
>>
>> private CellStyle createCellString(XSSFWorkbook wb, int c) {
>> CellStyle myCellStyleStyle= wb.createCellStyle();
>> XSSFFont myFont= wb.createFont();
>> myFont.setFontHeightInPoints((short)10);
>> myFont.setFontName("Arial");
>> //System.out.println("createCellString color = " + c +
>> "(" +
>> getColorName(c) + ")");
>> myFont.setColor((short) c);
>> myFont.setBold(c == getColorIndex("BLACK") ? false :
>> true);
>> myFont.setItalic(false);
>> myCellStyleStyle.setFont(myFont);
>> myCellStyleStyle.setAlignment((short) ALIGN_LEFT);
>> myCellStyleStyle.setVerticalAlignment(valign);
>> return myCellStyleStyle;
>> }
>>
>>
>>
>> Christopher Schene
>> Field Engineer
>> Global
>> Fraud and Identity Solutions
>>
>> Experian
>> 16260 N. 71st Street
>> Suite #400 ?Scottsdale
>> Arizona, USA
>> 85254
>> +1 602.290.9792 mobile
>> +1 480.751.3928 office
>> chris.schene@experian.com
>> www.experian.com <http://www.experian.com/>
>>
>>
>>
>>
>>
>> >
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
>> For additional commands, e-mail: user-help@poi.apache.org
>>
>>
Re: How do I left Align a cell?
Posted by Javen O'Neal <ja...@gmail.com>.
Make sure you call cell.setCellStyle(myCellStyle) when you're doing. You
may want to use CellUtil.setStyleProperties to avoid creating duplicate
styles or modifying the styles of other cells that share the same style.
On Jan 19, 2016 08:06, "Schene, Chris" <Ch...@experian.com> wrote:
> Hi,
>
> I am using this code to create a cell that I want left justified but it is
> showing up as centered
>
> private CellStyle createCellString(XSSFWorkbook wb, int c) {
> CellStyle myCellStyleStyle= wb.createCellStyle();
> XSSFFont myFont= wb.createFont();
> myFont.setFontHeightInPoints((short)10);
> myFont.setFontName("Arial");
> //System.out.println("createCellString color = " + c + "("
> +
> getColorName(c) + ")");
> myFont.setColor((short) c);
> myFont.setBold(c == getColorIndex("BLACK") ? false : true);
> myFont.setItalic(false);
> myCellStyleStyle.setFont(myFont);
> myCellStyleStyle.setAlignment((short) ALIGN_LEFT);
> myCellStyleStyle.setVerticalAlignment(valign);
> return myCellStyleStyle;
> }
>
>
>
> Christopher Schene
> Field Engineer
> Global
> Fraud and Identity Solutions
>
> Experian
> 16260 N. 71st Street
> Suite #400 ?Scottsdale
> Arizona, USA
> 85254
> +1 602.290.9792 mobile
> +1 480.751.3928 office
> chris.schene@experian.com
> www.experian.com <http://www.experian.com/>
>
>
>
>
>
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>