Set the number format of cells in an Excel file
来源:互联网 发布:用单片机做电子秤教程 编辑:程序博客网 时间:2024/04/30 09:22
Use the NumberFormat Excel property
This solution applies to external Excel files, not to the QuickTest Professional data table.
Excel's object methods are not part of QuickTest Professional, therefore, they are not guaranteed to work and are not supported by Mercury Technical Support. Any changes that Microsoft may make to these methods are not the responsibility of Mercury.
Example:
filename = "C:\temp\sample.xls"
Set ExcelObj = CreateObject("Excel.Application")
ExcelObj.Workbooks.Open filename
ExcelObj.Visible = True
Set NewSheet = ExcelObj.Sheets.Item(1)
' Format the Cells to General
'NewSheet.Columns("A").Select
NewSheet.Cells(1,1) = "test"
NewSheet.Cells(1,1).Select
ExcelObj.Selection.NumberFormat = "General"
' Format the cells to Percentage
NewSheet.Cells(1,2) = ".50"
NewSheet.Columns("B").Select
ExcelObj.Selection.NumberFormat = "##%"
' Format the cells to Currency
NewSheet.Cells(1,3) = "6.50"
NewSheet.Columns("C").Select
ExcelObj.Selection.NumberFormat = "$0.00"
ExcelObj.ActiveWorkbook.Save
ExcelObj.Application.Quit
Set ExcelObj = Nothing
0 0
- Set the number format of cells in an Excel file
- Counting-the-number-of-set-bits-in-an-integer
- Reducing the Number of Gray Levels in an Image
- Invalid update: invalid number of rows in section 0. The number of rows contained in an ....
- Updating the flat file of an iSCSI target in AIX
- An In-Depth Look into the Win32 Portable Executable File Format
- An In-Depth Look into the Win32 Portable Executable File Format
- An In-Depth Look into the Win32 Portable Executable File Format, Part 2
- An In-Depth Look into the Win32 Portable Executable File Format
- 【转】An In-Depth Look into the Win32 Portable Executable File Format
- An In-Depth Look into the Win32 Portable Executable File Format, Part 2
- HDU The Number of set
- 3006 The Number of set
- SQL Error:An aggregate may not appear in the set list of an UPDATE statement.
- [Store:280041]An record was found in the file store with an invalid version of 5
- "The file you are trying to open, '[filename]', is in a different format" Excel Error
- Warning: Could not merge cells C9-D9 as they clash with an existing set of merged cells.
- The format of Oracle tnsnames.ora file
- Python快速学习02:基本数据类型 & 序列
- Android 游戏引擎libgdx之Box2D
- 一道题的瞎想
- 黑马程序员-我的第十一篇学习日记:OC构造方法和分类的使用
- android Message 消息处理机制
- Set the number format of cells in an Excel file
- 驱动程序的基本结构
- BZOJ 2875 [NOI2012] 随机数生成器
- Python快速学习03:运算 & 缩进和选择
- 机器学习自学指南
- USACO Prime Cryptarithm
- 2.2.3 第三版:唯美主义的杰作
- 解放军要求全军和武警部队学习习近平论述摘编
- SharedPreferences保存android数据