> Of course I will Rob. At home now so it will take me a few hours to search the
code out. There is one limit
> however, I was working with just a single workbook and comparing styles within
the workbook so to speak. I
> know that problems can arise if you are using more than one workbook - for
example if you are copying over
> from one workbook to another - with fonts colours etc.

I'm in luck - one workbook, one worksheet - for now ;)

For yucks, I tried writing a function that createsappropriate cell types
from a string.  Pretty easy (not ready to try regex's yet, but...):

    // Add a new cell
    public void addCell(int rownum, int colnum, String text)
    {
        HSSFRow r = sheet.getRow((short) rownum);
        HSSFCell c = r.createCell((short) colnum);
        
        // Determine data type.  Try numeric first.
        try
        {
            double value = java.lang.Double.parseDouble(text);
            c.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
            c.setCellValue(value);
        }
        catch (NumberFormatException nfe)
        {
            // Not numeric, try date.
            try
            {
                SimpleDateFormat df = new SimpleDateFormat("MM/d/yy");
                Date date = df.parse(text);
                c.setCellStyle(datestyle);
                c.setCellValue(date);
            }
            catch (ParseException pe)
            {
                // Not date, default to text
                HSSFRichTextString s = new HSSFRichTextString(text);
                c.setCellStyle(orangecell);
                c.setCellType(HSSFCell.CELL_TYPE_STRING);
                c.setCellValue(s);
            }
        }
    }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to