LoginSignup
0
1

More than 5 years have passed since last update.

C++ Builder XE4 > Excel > セルC5に"3.141592"を代入する > 3.14となる

Last updated at Posted at 2018-06-27
動作環境
- 実装
    - C++ Builder XE4
- 確認
    - Windows 8.1 Pro
    - Office 2016

関連

処理概要

  • セルC5にString文字列"3.141592"を代入する

code v0.1

C++ Builder XE4 > Excel > 1行挿入して、別ファイル保存 | DisplayAlertsのオフ
のcode v0.2に対して、下記の変更をする。

変更前.cpp
xls_asheet.OlePropertyGet("Rows", 1).OleProcedure("Insert");
変更後.cpp
xls_asheet.OlePropertyGet("Cells", 5, 3).OlePropertySet("Value", String("3.141592").c_str());

Valueプロパティに対して、c_str()変換結果を代入する。

上記の例ではStringはUnicodeStringのため、c_str()の結果はWideStringになる。

結果

セルC5には"3.14"の値が入る。
少数第3桁以下がカットされる。

書式をNumberFormatLocalにて"0.00000"とした場合でも"3.14000"となる。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1