Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access v7.1
  HXTT Cobol v5.0
  HXTT DBF v7.1
  HXTT Excel v6.1
  Buy Now
  HXTT Json v1.0
  HXTT Paradox v7.1
  HXTT PDF v2.0
  HXTT Text(CSV) v7.1
  HXTT Word v1.1
  HXTT XML v4.0
Offshore Outsourcing
Free Resources
  Firewall Tunneling
  Search Indexing Robot
  Conditional Compilation
  Password Recovery for MS Access
  Password Recovery for Corel Paradox
  Checksum Tool for MD5
  Character Set Converter
  Pyramid - Poker of ZYH
Heng Xing Tian Tai Lab of Xi'an City (abbr, HXTT)

HXTT Excel
Edwin S. Ramirez
2007-10-28 07:34:00
Is it possible to specify formatting for the cells or rows in the Excel file when inserting?

In particular, I would like to format the header differently from the values.

-Edwin S. Ramirez-
HXTT Support
2007-10-28 17:45:40
>In particular, I would like to format the header differently from the values.
The simplest solution is preparing a blank .xls file which has that format. If you wish to insert column names too, you can use FirstRowHasNames=false connection property to do that.

>Is it possible to specify formatting for the cells or rows in the Excel file
> when inserting?
It's possible, but how to provide that feature through JDBC API. What's your want? fontName, fontSize, isItalic, colour, scriptStyle, underlineStyle, and/or boldWeight? We can complement that feature through some sql functions, for instance, setCellColour. You should email us an expectant format sample so that we can see whether we can complement that feature.
Edwin S. Ramirez
2007-10-29 05:20:59
Your first solution only works if I know what the header should contain ahead of time, which I won't.

Ideally, the Excel driver would provide the ability to define a style to use for each of the columns that are going to be inserted. For example:

db.setFont(1, "Times New Roman");
db.setSize(1, "14");

Where the first argument is the Excel cell. Or even better:

db.setStyle(1, "font=Times New Roman;size=14;fontWeight=bold;colspan=3;");

The next insert would use the predefined styles to format the cells. Of course, chainging the style of the same cells after rows have been writen, would only change the following rows.

Hope this helps!

-Edwin S. Ramirez-
HXTT Support
2007-10-29 07:32:10
>db.setStyle(1, "font=Times New Roman;size=14;fontWeight=bold;colspan=3;");
Good idea. Maybe a sql function,
setCellStyle(cXlsFileName,cSheetName,columnIndex,rowIndex,cStyle);//which cstyle can use "font=Times New Roman;size=14;fontWeight=bold;colspan=3;"
update sheet1 set _Style_="column=A;font=Times New Roman;size=14;fontWeight=bold;colspan=3;" where recno()=3;
I prefer using a specila column name for style change. What's your suggestion?
Edwin S. Ramirez
2007-10-29 07:52:47
I see where you are going, and I think is good. But we are looking at the problem from two different points of view. On the one hand, we could define style for the cells before we write them. While on the other hand, we could define the style after the rows have been written.

Considering that all the rows in each sheet (table) in the excel file will have the same structure, your update statement approach is very useful.

I guess a similar statement can be used to defined the header style (when the header was added directly by the driver).


-Edwin S. Ramirez-

Search Key   Search by Last 50 Questions


Copyright © 2003-2019 Heng Xing Tian Tai Lab of Xi'an City. | All Rights Reserved. | Privacy | Legal | Refund | Sitemap