Main   Products   Offshore Outsourcing   Customers   Partners   ContactUs  
JDBC Databases
  HXTT Access v5.2
  HXTT Cobol v2.1
  HXTT DBF v5.2
  HXTT Excel v4.2
  Buy Now
  HXTT Paradox v5.2
  HXTT Text(CSV) v5.2
  HXTT XML v1.2
Offshore Outsourcing
Oracle Data Import/Export
DB2 Data Import/Export
Sybase Data Import/Export
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
Hongxin Technology & Trade Ltd. of Xiangtan City (abbr, HXTT)

HXTT Excel
Edwin S. Ramirez
2007-10-28 07:34:00.0
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.0
>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.0
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.0
>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.0
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


Address: 9 Station Rd., Xiangtan City, Hunan Province, P.R. China
Postcode: 411100
Phone: (86)731-58225727
Fax: (86)731-58225727
Copyright © 1999-2011 Hongxin Technology & Trade Ltd. | All Rights Reserved. | Privacy | Legal | Sitemap