Java POI non-static method getFormat(java.lang.String) cannot be referenced from a static context

Just installed POI 3.8 jars and changing over code...I get this error:

 public static void setStyleDataFormat( CellStyle style, int formatType )
{
    switch( formatType )
    {
        case CELL_TYPE_PERCENTAGE:

            style.setDataFormat(DataFormat.getFormat("0%"));
            break;

        case CELL_TYPE_PERCENTAGE_TWO_DECIMAL_PLACES:

            style.setDataFormat(DataFormat.getFormat("0.00%"));
            break;

        case CELL_TYPE_NUMERIC:

            style.setDataFormat(DataFormat.getFormat("#,##0"));
            break;

        case CELL_TYPE_NUMERIC_TWO_DECIMAL_PLACES:

            style.setDataFormat(DataFormat.getFormat("#,##0.00"));
            break;

        case CELL_TYPE_DATE:
        case CELL_TYPE_DATE_EMPTY_ON_ERROR:

            style.setDataFormat(DataFormat.getFormat("m/d/yy"));
            break;

        case CELL_TYPE_CURRENCY:

            style.setDataFormat(DataFormat.getFormat("($#,##0.00);($#,##0.00)"));
            break;

        case CELL_TYPE_CURRENCY_NO_CENTS:

            style.setDataFormat(DataFormat.getFormat("($#,##0_);($#,##0)"));
            break;
    }
}

non-static method getFormat(java.lang.String) cannot be referenced from a static context

Answers


This page should be able to help you fix this. It seems that Apache decided you shouldn't be so static.


Need Your Help

Moving eclipse with plugins to another pc

eclipse java-ee eclipse-plugin

I have installed Web, XML, Java EE and OSGI Enterprise Development plugins to my Eclipse Indigo (windows 7 machine). Now, I can create Web project using

How to Add a link to Bootstrap Select Options

jquery html css twitter-bootstrap href

Hi I'm trying to add a link to a Bootstrap Select Option. How I do that

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.