From: Nick Burch Date: Fri, 30 Sep 2011 19:30:15 +0000 (+0000) Subject: Add a HSSF/XSSF example relating to cell styles and colours X-Git-Tag: REL_3_8_BETA5~116 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=3cac9ec7384eee912f4ed3159d7d1e4ce7be8293;p=poi.git Add a HSSF/XSSF example relating to cell styles and colours git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1177793 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/examples/src/org/apache/poi/ss/examples/CellStyleDetails.java b/src/examples/src/org/apache/poi/ss/examples/CellStyleDetails.java new file mode 100644 index 0000000000..8dab14fa7a --- /dev/null +++ b/src/examples/src/org/apache/poi/ss/examples/CellStyleDetails.java @@ -0,0 +1,94 @@ +/* ==================================================================== + Licensed to the Apache Software Foundation (ASF) under one or more + contributor license agreements. See the NOTICE file distributed with + this work for additional information regarding copyright ownership. + The ASF licenses this file to You under the Apache License, Version 2.0 + (the "License"); you may not use this file except in compliance with + the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +==================================================================== */ +package org.apache.poi.ss.examples; + +import java.io.File; + +import org.apache.poi.hssf.usermodel.HSSFFont; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.hssf.util.HSSFColor; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.Color; +import org.apache.poi.ss.usermodel.DataFormatter; +import org.apache.poi.ss.usermodel.Font; +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.usermodel.WorkbookFactory; +import org.apache.poi.ss.util.CellReference; +import org.apache.poi.xssf.usermodel.XSSFColor; +import org.apache.poi.xssf.usermodel.XSSFFont; + +/** + * Demonstrates how to read excel styles for cells + */ +public class CellStyleDetails { + public static void main(String[] args) throws Exception { + if(args.length == 0) { + throw new IllegalArgumentException("Filename must be given"); + } + + Workbook wb = WorkbookFactory.create(new File(args[0])); + DataFormatter formatter = new DataFormatter(); + + for(int sn=0; sn