千葉真子の推薦のウォーキングマシン(ルームマーチウォーク)を購入しました。冬になると雪が降って外に散歩にでるのがおっくうになるので、このマシンで室内で運動することができます。なお、約30分間、動作すると自動的に止まります。
また保証期間は半年
間です。
http://www.youtube.com/watch?v=hkEKutLEYLc
なお、以下の商品は、値段が上のものよりは安いのですが、同じものなのか違うものなのかよくわからないです。
2012年12月30日日曜日
2012年12月29日土曜日
C# でExcelからチャートを作成
C# でExcelファイルからチャートを作成するサンプルです。
予め、chart1 という名前のチャートコントロールをフォームに配置しておきます。\temp.xls というExcelファイルのシート名6954の領域B1~D250に表が作成されている状態で実行します。(1行目の領域B1~D1には、hiduke,svalue,hvalue などのフィールド名が記述されています。実際の数値は領域B2~D250に記述されています。)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void Form1_Load(object sender, EventArgs e) | |
{ | |
// The Excel file name | |
string fileNameString = "\\temp.xls"; | |
// Create connection object by using the preceding connection string. | |
string sConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + | |
fileNameString + ";Extended Properties=\"Excel 8.0;HDR=YES\""; | |
OleDbConnection myConnection = new OleDbConnection( sConn ); | |
myConnection.Open(); | |
// The code to follow uses a SQL SELECT command to display the data from the worksheet. | |
// Create new OleDbCommand to return data from worksheet. | |
OleDbCommand myCommand = new OleDbCommand( "Select * From [6954$B1:D250]", myConnection ); | |
// create a database reader | |
OleDbDataReader myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection); | |
// Populate the chart with data in the file | |
chart1.DataBindTable(myReader, "hiduke"); | |
//chart1.Series[0].ChartType = SeriesChartType.Line; | |
chart1.Series["svalue"].ChartType = SeriesChartType.Line; | |
chart1.Series["hvalue"].ChartType = SeriesChartType.Line; | |
// close the reader and the connection | |
myReader.Close(); | |
myConnection.Close(); | |
} |
2012年12月27日木曜日
2.0TB のハードディスク(HDD)を購入
2.0TB のハードディスク(HDD)をアマゾンで購入しました。またこのHDDは、SATAですが、SATA → IDE変換アダプタ(コネクタ)(変換名人)を合わせて購入しました。パソコンが古いので、SATAではなくてIDEのケーブルがついており、これに接続するためです。接続して問題なくハードディスクが認識できたので安心しました。ただし変換名人のIDE側のコネクタのほうがきつくて、いったん差し込むとなかなか抜けません。
WD Green 3.5inch IntelliPower 2.0TB 64MBキャッシュ SATA3.0 WD20EZRX/N
http://www.amazon.co.jp/gp/product/B009QWUF6M/ref=oh_details_o01_s00_i00
TFTEC JAPAN SATA → IDE変換アダプタ(コネクタ) IDE-SATAZD2(変換名人)
http://www.amazon.co.jp/gp/product/B004R9KPMI/ref=oh_details_o01_s00_i01
WD Green 3.5inch IntelliPower 2.0TB 64MBキャッシュ SATA3.0 WD20EZRX/N
http://www.amazon.co.jp/gp/product/B009QWUF6M/ref=oh_details_o01_s00_i00
TFTEC JAPAN SATA → IDE変換アダプタ(コネクタ) IDE-SATAZD2(変換名人)
http://www.amazon.co.jp/gp/product/B004R9KPMI/ref=oh_details_o01_s00_i01
2012年12月26日水曜日
iPod用のイヤホンを買った
iPod用に使っていたイヤホンが壊れた(右側が聞こえなくなった)ので、新しいものをアマゾンで発注しました。1,000円ぐらいするかと思っていたのですが、安いのがあったので、思わずポチってしまいました。(242円でした。)カスタマープレビューでは「安いのに高音質」という評価だったので、どんなものが届くか楽しみでした。100円ショップで買えるものよりはよいものであればぐらいに思って少し期待していました。実際に届いてみると雑音が少なく音は確かにきれいだと思いました。あとはどれだけ長持ちするかだと思います。
発注した242円のもの
PLANEX iPhone4s/iPod/スマートフォン対応 ステレオイヤホン PL-EP01
http://www.amazon.co.jp/dp/B0052BPKL6/ref=pe_302852_34649732_3p_dp_1
参考まで
Apple iPodイヤフォン(2006) MA662G/B
http://www.amazon.co.jp/%E3%82%A2%E3%83%83%E3%83%97%E3%83%AB-MA662G-B-Apple-iPod%E3%82%A4%E3%83%A4%E3%83%95%E3%82%A9%E3%83%B3/dp/B000IK250U/ref=cm_cr_pr_product_top
2012年12月25日火曜日
Perl でAccessデータベースに接続するサンプル(その2)
Perl でAccessデータベースに接続するサンプル(その2)
以下のサンプルでは、C:\mdb\book.mdb というAccessデータベースに接続して,book というテーブルの中の title と isbn というフィールドの値を表示しています。ADODB.Connection をnew するところと、クエリーを実行するところでエラー発生時にメッセージを表示できるように、' or die ~'の句が挿入されています。
-------------------------------------
use strict;
use Win32::OLE;
use utf8;
my $conn = "Provider=Microsoft.Jet.OLEDB.4.0;";
$conn .= "Data Source=c:\\mdb\\book.mdb;";
my $db = Win32::OLE->new("ADODB.Connection") or die "CreateObject: $!";
$db->Open($conn);
my $query = "select * from book;";
my $result = $db->Execute($query) or die join ' ', map { $db->Errors->Item($_)->Description } (0 .. $db->Errors->Count - 1);
while (!$result->EOF) {
print $result->Fields('title')->Value . " " . $result->Fields('isbn')->Value . "\n";
$result->MoveNext;
}
$result->Close();
$db->Close();
------------------------------------
以下のサンプルでは、C:\mdb\book.mdb というAccessデータベースに接続して,book というテーブルの中の title と isbn というフィールドの値を表示しています。ADODB.Connection をnew するところと、クエリーを実行するところでエラー発生時にメッセージを表示できるように、' or die ~'の句が挿入されています。
-------------------------------------
use strict;
use Win32::OLE;
use utf8;
my $conn = "Provider=Microsoft.Jet.OLEDB.4.0;";
$conn .= "Data Source=c:\\mdb\\book.mdb;";
my $db = Win32::OLE->new("ADODB.Connection") or die "CreateObject: $!";
$db->Open($conn);
my $query = "select * from book;";
my $result = $db->Execute($query) or die join ' ', map { $db->Errors->Item($_)->Description } (0 .. $db->Errors->Count - 1);
while (!$result->EOF) {
print $result->Fields('title')->Value . " " . $result->Fields('isbn')->Value . "\n";
$result->MoveNext;
}
$result->Close();
$db->Close();
------------------------------------
2012年12月24日月曜日
Accessのパスワードを忘れてしまった
数年前に作成したAccessのデータベースにパスワードをかけていたのですが、そのパスワードを忘れてしまい開けなくなっていました。以下のサイトを参考にさせて頂き、忘れていたパスワードを調べることができました。
http://pucyan.blog77.fc2.com/blog-entry-46.html
http://www.everythingaccess.com/downloads.asp
使用したのは、Access Password Retrieval Lite (FREEWARE) というツールです。このツールではAccess95/97/2000/2002(XP)/2003 をサポートしています。
http://pucyan.blog77.fc2.com/blog-entry-46.html
http://www.everythingaccess.com/downloads.asp
使用したのは、Access Password Retrieval Lite (FREEWARE) というツールです。このツールではAccess95/97/2000/2002(XP)/2003 をサポートしています。
Perl で Accessデータベースに接続
Perl スクリプトで Access データベース(mdb)に接続して、テーブルの内容を表示するサンプルです。access2007 のデータベースで試しました(どうもaccess97のmdbデータだとうまく動作しないようです。)
以下のサイトを参考にさせて頂きました。
http://www.tryhp.net/OLE.htm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/perl | |
use Win32::OLE; | |
$conn = "Provider=Microsoft.Jet.OLEDB.4.0;"; | |
$conn .= "Data Source=c:\\mdb\\addressbook_2007.mdb;"; | |
$db = Win32::OLE->new("ADODB.Connection"); | |
$db->Open($conn); | |
$rs = $db->Execute("SELECT * FROM アドレス帳テーブル;"); | |
while (!$rs->EOF) { | |
print $rs->{Fields}->{'漢字氏名'}->{Value},","; | |
print $rs->{Fields}->{'カナ氏名'}->{Value},"\n"; | |
$rs->MoveNext; | |
} | |
$rs->Close(); | |
$db->Close(); | |
exit; |
以下のサイトを参考にさせて頂きました。
http://www.tryhp.net/OLE.htm
2012年12月20日木曜日
C# でCSV形式のテキストファイルを読み込む
C# でCSV形式のテキストファイルを読み込むサンプル(テキストファイルはc:\mdb\zzz.txt)参照の追加でMicrosoft VisualBasic を追加しておく必要があります。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using Microsoft.VisualBasic.FileIO; | |
namespace cs_read_csv | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
TextFieldParser parser = new TextFieldParser(@"C:\mdb\zzz.txt", Encoding.GetEncoding("Shift_JIS")); | |
parser.TextFieldType = FieldType.Delimited; | |
parser.SetDelimiters(","); // 区切り文字はコンマ | |
while (!parser.EndOfData) | |
{ | |
string[] row = parser.ReadFields(); // 1行読み込み | |
Console.WriteLine(row[0] + "," + row[1] + "," + row[2]); | |
} | |
Console.ReadLine(); | |
} | |
} | |
} | |
C#で 2か月前の日付の文字列を得る
C#で今日の日付と2か月前の日付の文字列を得るサンプル
string kyounohiduke = DateTime.Today.ToString("yyyy/MM/dd");
string nikagetsumae = DateTime.Today.AddMonths(-2).ToString("yyyy/MM/dd");
string kyounohiduke = DateTime.Today.ToString("yyyy/MM/dd");
string nikagetsumae = DateTime.Today.AddMonths(-2).ToString("yyyy/MM/dd");
C# でAccessデータベースをチャート化
C# でAccessデータベースの内容を取り出してチャートを表示するサンプルです。
予めAccessのmdbに、株価のデータを格納しておきます。(データベース名は、c:\mdb\stock_mdb.mdbです。テーブル名は、stock_mdb です。フィールド名は、meigara,hiduke,evalue,hvalue などです。)
また予めフォームにチャートコントロールを張り付けておきます。引数として、code と miniYを与えます。
code は銘柄コードでテーブルのmeigara に相当します。miniYはチャートの表示の下限を表します。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void display_chart(int code , int miniY) | |
{ | |
chart1.ChartAreas[0].AxisY.Minimum = miniY; | |
String meigara = code.ToString(); | |
// Resolve the address to the Access database | |
// string fileNameString = @"stock_mdb.mdb"; | |
string fileNameString = @"c:\mdb\stock_mdb.mdb"; | |
// Initialize a connection string | |
string myConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileNameString; | |
// Define the database query | |
string mySelectQuery = "SELECT * FROM table_stock where meigara='" + meigara + "' order by hiduke;"; | |
// Create a database connection object using the connection string | |
OleDbConnection myConnection = new OleDbConnection(myConnectionString); | |
// Create a database command on the connection using query | |
OleDbCommand myCommand = new OleDbCommand(mySelectQuery, myConnection); | |
myConnection.Open(); | |
// set chart data source - the data source must implement IEnumerable | |
chart1.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection); | |
// Set series members names for the X and Y values | |
chart1.Series[0].XValueMember = "hiduke"; | |
chart1.Series[0].YValueMembers = "evalue"; | |
chart1.Series[0].ChartType = SeriesChartType.Line; | |
chart1.Series[1].XValueMember = "hiduke"; | |
chart1.Series[1].YValueMembers = "hvalue"; | |
chart1.Series[1].ChartType = SeriesChartType.Line; | |
// Data bind to the selected data source | |
//chart1.DataBind(); | |
} |
2012年12月19日水曜日
C# で Excel のセルを読み書き
C# (Visual Studio 2012 express)で Excel ファイルのA1セルを読み書きする処理
参考にさせてもらったサイト
http://code.msdn.microsoft.com/office/C-Excel-Sheet-5037d251
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Microsoft.Office.Interop.Excel; | |
namespace COMAutomation_Excel_CS | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
string fileName = @"C:\mdb\temp2.xlsx"; | |
Application xlApp = new Application(); | |
if (xlApp != null) | |
{ | |
xlApp.Visible = true; | |
Workbook wb = xlApp.Workbooks.Open(Filename: fileName); | |
((Worksheet)wb.Sheets[1]).Select(); | |
Range aRange = xlApp.get_Range("A1") as Range; | |
if (aRange != null) | |
{ | |
Console.WriteLine(aRange.Value2 ?? String.Empty); | |
aRange.Value2 = "コード レシピ Excel編"; | |
Console.WriteLine(aRange.Value2); | |
} | |
wb.Close(true); | |
xlApp.Quit(); | |
} | |
} | |
} | |
} |
2012年12月16日日曜日
C# でAccessデータベースに接続(コンソールプログラム)
C# でAccessデータベースに接続してテーブルのフィールドを表示するサンプルプログラム
以下のサイトを参考にさせて頂きました。
http://www.dscripts.net/2009/01/20/connect-to-microsoft-access-mdb-database-using-csharp/
以下のサンプルではc:\mdb\stock_mdb.mdb というAccessデータベースに接続してmeigara というテーブルのフィールドを表示しています。
以下のサイトを参考にさせて頂きました。
http://www.dscripts.net/2009/01/20/connect-to-microsoft-access-mdb-database-using-csharp/
以下のサンプルではc:\mdb\stock_mdb.mdb というAccessデータベースに接続してmeigara というテーブルのフィールドを表示しています。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Data.OleDb; | |
using System.Data; | |
using System.Xml.Serialization; | |
namespace ConsoleApplication2 | |
{ | |
public class Program | |
{ | |
private static OleDbConnection con; | |
static void Main() | |
{ | |
try | |
{ | |
con = new OleDbConnection( | |
@"Provider=Microsoft.JET.OLEDB.4.0;" | |
+ @"data source=c:\mdb\stock_mdb.mdb;Jet OLEDB" | |
+":Database Password="); | |
con.Open(); //connection must be openned | |
OleDbCommand cmd = new OleDbCommand( | |
"SELECT * from meigara", con); | |
OleDbDataReader reader = cmd.ExecuteReader(); | |
while(reader.Read()) // if can read row from database | |
{ | |
Console.WriteLine(reader.GetValue(1).ToString() | |
+ " = " + reader.GetValue(2).ToString()); | |
} | |
} | |
catch(Exception ex) | |
{ | |
Console.WriteLine("Ex: "+ex); | |
} | |
finally | |
{ | |
con.Close(); // finally closes connection | |
} | |
} | |
} | |
} |
2012年12月15日土曜日
C# で Accessのmdb に接続
C# で Accessのmdb に接続してテーブルの中のフィールドの値を表示するサンプル。
以下のサイトを参照させて頂きました。
http://sunaolabo.blog32.fc2.com/blog-entry-38.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Data; | |
using System.Drawing; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Windows.Forms; | |
namespace cs_access | |
{ | |
public partial class Form1 : Form | |
{ | |
System.Data.OleDb.OleDbConnection conn; | |
DataTable dtUser; | |
private bool conectAcessDB(string strDbPath, string strPasswd, ref System.Data.OleDb.OleDbConnection con) | |
{ | |
// --- 接続文字列 | |
string conString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="; | |
conString += strDbPath + ";Jet OLEDB:Database Password=" + strPasswd; | |
con = new System.Data.OleDb.OleDbConnection(conString); | |
try | |
{ | |
// --- DB Open | |
con.Open(); | |
// --- DB Close | |
con.Close(); | |
return true; | |
} | |
catch | |
{ | |
return false; | |
} | |
} | |
/// <summary> | |
// --------------------------------------------------------- | |
// * Function : getDatTableSQL | |
// * Operation : SQL文に従ってデータテーブルに取込む | |
// --------------------------------------------------------- | |
/// </summary> | |
private bool getDbTableSQL(string strSQL, ref System.Data.DataTable dt) | |
{ | |
bool ret = false; | |
if (strSQL != "") | |
{ | |
System.Data.OleDb.OleDbDataAdapter da = | |
new System.Data.OleDb.OleDbDataAdapter(strSQL, conn); | |
// --- DataTableに格納する | |
dt = new System.Data.DataTable(); | |
try | |
{ | |
da.Fill(dt); | |
ret = true; | |
} | |
catch | |
{ | |
string strTitle = "選択クエリー"; | |
string strPrompt = "クエリーに失敗しました。"; | |
MessageBox.Show(strPrompt, strTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); | |
} | |
} | |
return ret; | |
} | |
public Form1() | |
{ | |
InitializeComponent(); | |
} | |
private void Form1_Load(object sender, EventArgs e) | |
{ | |
string strDBPath = @"C:\mdb\stock_mdb.mdb"; // --- データベースパス | |
string strDBPassword = ""; // --- データベースパスワード | |
// ---------------------------------------------------------------------- | |
string strSQL; // --- SQL文 | |
bool ret = false; | |
int i; | |
// --- DB接続 | |
ret = conectAcessDB(strDBPath, strDBPassword, ref conn); | |
strSQL = "SELECT meigara,namae FROM meigara; "; | |
// --- SQL文のデータテーブルを取得 | |
ret = getDbTableSQL(strSQL, ref dtUser); | |
if (dtUser.Rows.Count > 0) | |
{ | |
for (i = 0; i < dtUser.Rows.Count; i++) | |
{ | |
// --- ユーザー名コンボボックスへアイテム追加 | |
//cmbUserName.Items.Add(dtUser.Rows[i][0].ToString()); | |
MessageBox.Show(dtUser.Rows[i][1].ToString()); | |
} | |
} | |
// --- リソース解放 | |
dtUser.Dispose(); | |
conn.Dispose(); | |
} | |
} | |
} |
C# でExcelファイルに書き込む
C# でExcelファイルに書き込むサンプルです。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Data; | |
using System.Drawing; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Windows.Forms; | |
using Excel = Microsoft.Office.Interop.Excel; | |
namespace cs_excel_write2 | |
{ | |
public partial class Form1 : Form | |
{ | |
public Form1() | |
{ | |
InitializeComponent(); | |
} | |
private void button1_Click(object sender, EventArgs e) | |
{ | |
// string ExcelBookFileName = textBox3.Text; | |
// string ExcelBookFileName = "c:\\mdb\\temp2.xlsx"; | |
// Microsoft.Office.Interop.Excel.Application ExcelApp | |
// = new Microsoft.Office.Interop.Excel.Application(); | |
Excel.Application ExcelApp | |
= new Excel.Application(); | |
ExcelApp.Visible = true; | |
Excel.Workbook wb = ExcelApp.Workbooks.Add(); | |
Excel.Worksheet ws1 = wb.Sheets[1]; | |
ws1.Select(Type.Missing); | |
for (int i = 1; i < 20; i++) | |
{ | |
Excel.Range rgn = ws1.Cells[i, 1]; | |
rgn.Value2 = i; | |
} | |
wb.SaveAs("c:\\mdb\\temp3.xlsx"); | |
wb.Close(false); | |
ExcelApp.Quit(); | |
} | |
} | |
} |
参考にさせて頂いたサイト
http://www.ipentec.com/document/document.aspx?page=csharp-save-excel-new-file-and-write&culture=ja-jp
読み込むサンプルは以下です。
http://chaos-fractal.blogspot.jp/2012/12/c-excel.html
C# でExcelファイルにアクセス
C# でExcelファイルにアクセスするサンプル
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Data; | |
using System.Drawing; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Windows.Forms; | |
using Excel = Microsoft.Office.Interop.Excel; | |
namespace cs_excel | |
{ | |
public partial class Form1 : Form | |
{ | |
public Form1() | |
{ | |
InitializeComponent(); | |
} | |
// 指定されたワークシート名のインデックスを返すメソッド | |
private int getSheetIndex(string sheetName, Excel.Sheets shs) | |
{ | |
int i = 0; | |
foreach (Excel.Worksheet sh in shs) | |
{ | |
if (sheetName == sh.Name) | |
{ | |
return i + 1; | |
} | |
i += 1; | |
} | |
return 0; | |
} | |
private void Form1_Load(object sender, EventArgs e) | |
{ | |
string excelName = "C:\\temp.xls"; | |
Excel.Application oXls; // Excelオブジェクト | |
Excel.Workbook oWBook; // workbookオブジェクト | |
oXls = new Excel.Application(); | |
oXls.Visible = true; // 確認のためExcelのウィンドウを表示する | |
// Excelファイルをオープンする | |
oWBook = (Excel.Workbook)(oXls.Workbooks.Open( | |
excelName, // オープンするExcelファイル名 | |
Type.Missing, // (省略可能)UpdateLinks (0 / 1 / 2 / 3) | |
Type.Missing, // (省略可能)ReadOnly (True / False ) | |
Type.Missing, // (省略可能)Format | |
// 1:タブ / 2:カンマ (,) / 3:スペース / 4:セミコロン (;) | |
// 5:なし / 6:引数 Delimiterで指定された文字 | |
Type.Missing, // (省略可能)Password | |
Type.Missing, // (省略可能)WriteResPassword | |
Type.Missing, // (省略可能)IgnoreReadOnlyRecommended | |
Type.Missing, // (省略可能)Origin | |
Type.Missing, // (省略可能)Delimiter | |
Type.Missing, // (省略可能)Editable | |
Type.Missing, // (省略可能)Notify | |
Type.Missing, // (省略可能)Converter | |
Type.Missing, // (省略可能)AddToMru | |
Type.Missing, // (省略可能)Local | |
Type.Missing // (省略可能)CorruptLoad | |
)); | |
// 与えられたワークシート名から、Worksheetオブジェクトを得る | |
string sheetName = "sheet1"; | |
Excel.Worksheet oSheet; // Worksheetオブジェクト | |
oSheet = (Excel.Worksheet)oWBook.Sheets[ | |
getSheetIndex(sheetName, oWBook.Sheets)]; | |
string sCellVal; | |
Excel.Range rng; // Rangeオブジェクト | |
rng = (Excel.Range)oSheet.Cells[1, 1]; | |
sCellVal = rng.Text.ToString(); // A1セルの内容 | |
MessageBox.Show(sCellVal); | |
oXls.Quit(); | |
//COM解放 | |
System.Runtime.InteropServices.Marshal.ReleaseComObject(oXls); | |
} | |
} | |
} |
なお予めExcelのCOMコンポーネントへの参照をプロジェクトに追加する必要があります。これには[参照の追加]ウィンドウで[COM]タブを選択し、「Microsoft Excel 15.0 Object Library」(Excel 2013の場合。Excel 2007の場合は「Microsoft Excel 12.0 Object Library」を選択します)。
以下を参考にさせていただきました。 http://www.atmarkit.co.jp/fdotnet/dotnettips/717excelfile/excelfile.html
2012年12月13日木曜日
c 言語 で時間を表示する
c言語 でその時点での時間を表示するサンプル。なお11:32~12:28の間であれば1を返し、それ以外は0を返します。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <time.h> | |
int main(void) | |
{ | |
time_t timer; | |
struct tm *t_st; | |
/* 現在時刻の取得 */ | |
time(&timer); | |
/* 現在時刻を文字列に変換して表示 */ | |
printf("現在時刻: %s\n", ctime(&timer)); | |
/* 現在時刻を構造体に変換 */ | |
t_st = localtime(&timer); | |
printf("月: %d\n",t_st->tm_mon+1); /* 月は+1 */ | |
printf("日: %d\n",t_st->tm_mday); | |
printf("時: %d\n",t_st->tm_hour); | |
printf("分: %d\n",t_st->tm_min); | |
printf("秒: %d\n",t_st->tm_sec); | |
if( t_st->tm_hour == 11 && t_st->tm_min > 32 ) return 1; | |
if( t_st->tm_hour == 12 && t_st->tm_min < 28 ) return 1; | |
return 0; | |
} |
2012年12月12日水曜日
Visual Studio 2012 Express for Windows Desktop
マイクロソフトのサイトでVisual Studio 2012 Express for Windows Desktop 日本語 をダウンロードしました。
http://www.microsoft.com/visualstudio/jpn/downloads#d-express-windows-desktop
ダウンロードが終了すると、VS2012_WDX_JPN.isoというファイルができているのでこれをダブルクリックしてドライブにマウントします。(Windows8からは、isoファイルをダブルクリックすると自動的にドライブにマウントされるようになりました。)
できたドライブの中にwdexpress_full.exeというファイルがあるので、これをダブルクリック。次の画面で「ライセンス条項に同意する」のチェックをいれて「インストール」をクリックするとインストールが始まりました。
その後アップデートをインストールしてVisualStudioが使用できるようになりました。
2012年12月11日火曜日
Perl でyahooのページから株価を取得する
perl でyahooのページから株価を取得するサンプル(以下のサンプルでは、東京電力の株価を取得して表示)
以前にもWeb::Scraperを使った似たような内容の投稿を書いています。
http://chaos-fractal.blogspot.jp/2011/12/perl.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
use strict; | |
use warnings; | |
use Web::Scraper; | |
use URI; | |
use Encode; | |
my $scraper = scraper { | |
process '//dl[@class="stocksInfo"]/dt[1]','numb' => 'TEXT'; | |
process '//table[@class="stocksTable"]/tr[1]/th[1]','name' => 'TEXT'; | |
process '//table[@class="stocksTable"]/tr[1]/td[2]','price' => 'TEXT'; | |
process '//dl[@class="stocksInfo"]/dd[3]/span[1]','jikoku' => 'TEXT'; | |
}; | |
my $res = $scraper->scrape(URI->new("http://stocks.finance.yahoo.co.jp/stocks/detail/?code=9501.t")); | |
print $res->{numb}."\n"; | |
#print encode('shift-jis',$res->{name})."\n"; | |
print encode('sjis',$res->{name})."\n"; | |
print $res->{price}."\n"; | |
print $res->{jikoku}."\n"; |
http://chaos-fractal.blogspot.jp/2011/12/perl.html
Windows8のために
Windows8を購入する前にメモリを増設しハードディスクも新しく買ってWindows8 Enterprise90日間評価版をインストールしてみました。
http://technet.microsoft.com/ja-JP/evalcenter/hh699156.aspx …
それに、DSP版Windows7 Home Premiumも購入しました。(アマゾンで9,750円)
Windows8Proを1,200円で購入したのは事実ですがそれ以前にWindows8のためにそれなりに投資したのだなと自分でも思います。
http://technet.microsoft.com/ja-JP/evalcenter/hh699156.aspx …
それに、DSP版Windows7 Home Premiumも購入しました。(アマゾンで9,750円)
Windows8Proを1,200円で購入したのは事実ですがそれ以前にWindows8のためにそれなりに投資したのだなと自分でも思います。
2012年12月8日土曜日
Office Professional 2013 プレビュー
Office Professional 2013 プレビューをインストールしました。インストール元は以下のサイトです。
http://www.microsoft.com/ja-jp/office/preview/office2013.aspx
なお、LibreOfficeのWriterで、文章を作成して、Office2013のWordで開いたところ、最後の行が表示されないことがありました。最後の行の後ろに改行をいくつかいれると表示されるようになりました。
USBメモリ8GBを買う
昨日 imation 社(台湾)のUSB Flash Drive(USBメモリ)8GBを購入しました。360°回転式キャップがついているのが特徴です。
imation NANO-f 8GB NATURAL ORANGE
ジョーシンで税込780円でした。
imation NANO-f 8GB NATURAL ORANGE
ジョーシンで税込780円でした。
Unetbootin をダウンロード
ダウンロードしたisoファイルをUSBメモリに書き込んで、USBメモリからブート出来るようにするためのツールとしてUnetbootinをダウンロードしました。
ダウンロード元はこちら
http://unetbootin.sourceforge.net/
日本語の説明はこちら
http://myusuke-plus.jp/archives/1162
ダウンロード元はこちら
http://unetbootin.sourceforge.net/
日本語の説明はこちら
http://myusuke-plus.jp/archives/1162
2012年12月6日木曜日
Windows8を使った感想
Windows8はやっぱりデスクトップにスタートボタンがないので慣れるまでは使いにくいですね。始めは電源を落とすのはどうしたらよいの?コントロールパネルを出すには?コマンドプロンプトはどうやって?という感じでした。
マウスを画面の右上か右下に持っていくとメニューが右から出てくるのでそこから始まりです。「設定」を選ぶと電源を落としたりコントロールパネルに移動したりできます。
Windows8は使いにくいのですが、前にそのPCで使っていたWindowsVistaに比べれば早くなったなあという感じです。いったんデスクトップに入れば以前のWindowsに近い感じで使えます。
画面の左下で右クリックするとコマンドプロンプトなどが使用できるメニューがでてきます。
今いる画面を閉じて元の画面に戻るには、Alt+F4キーを使うと便利です。
Windows8に慣れるために、ハードディスクを新規に購入してWindows8Enterprise90日間評価版というのをインストールして使用しました。
参考URL
Windows 8はマウス・キーボードでも操作できるの?
http://extras.jp.msn.com/windows8/win8gimon/article.aspx?cp-documentid=251088647
Windows8 のショートカットキー4つ
http://d.hatena.ne.jp/Shingi/20121025/1351174736
2012年12月1日土曜日
Ubuntu 12.10 で wine
Windows上で動作するプログラムを、Ubuntuでも動作させることのできる wine というプログラムを使用しています。
はじめは コマンドラインから wine と入力すると以下のように入力するように求められますのでそのとおりに入力するとwine プログラムは使用できるようになりました。
sudo apt-get install wine1.4-i386
私の場合には、SecMail.exe というWindowsプログラムを使用するのでそのプログラムをホームディレクトリに配置した上で以下のように入力して起動します。
wine SecMail.exe
また、このSecMail.exeというファイルに実行権をつけると、wine と入力しなくてもそのまま起動できるようになります。
chmod a+x SecMail.exe (実行権をつける)
./SecMail.exe (このコマンドだけで起動できるようになる)
はじめは コマンドラインから wine と入力すると以下のように入力するように求められますのでそのとおりに入力するとwine プログラムは使用できるようになりました。
sudo apt-get install wine1.4-i386
私の場合には、SecMail.exe というWindowsプログラムを使用するのでそのプログラムをホームディレクトリに配置した上で以下のように入力して起動します。
wine SecMail.exe
また、このSecMail.exeというファイルに実行権をつけると、wine と入力しなくてもそのまま起動できるようになります。
chmod a+x SecMail.exe (実行権をつける)
./SecMail.exe (このコマンドだけで起動できるようになる)
英会話学習用Podcast
英会話の学習用Podcast としてよく聞いているのは以下の二つ
Gaba G Style English~シチュエーション別英会話~
By Gaba
Gaba G Style English~シチュエーション別英会話~
By Gaba
https://itunes.apple.com/us/podcast/id168407898
ECC 英会話 Podcasting 知ってる単語でこんなに話せる!
By ECC
By ECC
https://itunes.apple.com/podcast/ecc-ying-hui-hua-podcasting/id124528617?mt=2
登録:
投稿 (Atom)