<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>C#でExcelを読み込んで操作する方法を公開｜C# Excel操作テクニック.NET &#187; Excelｱﾌﾟﾘｹｰｼｮﾝ操作</title>
	<atom:link href="http://excelcsharp.lance40.com/category/app/feed" rel="self" type="application/rss+xml" />
	<link>http://excelcsharp.lance40.com</link>
	<description>メソッドに貼り付けるだけで機能するソースコードを多数用意しています。</description>
	<lastBuildDate>Sun, 08 Nov 2015 04:41:39 +0000</lastBuildDate>
	<language>ja</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=3.7.41</generator>
	<item>
		<title>Excelアプリケーション(Excel.exe)のパスを取得する</title>
		<link>http://excelcsharp.lance40.com/excelpath.html</link>
		<comments>http://excelcsharp.lance40.com/excelpath.html#comments</comments>
		<pubDate>Fri, 29 Nov 2013 12:34:25 +0000</pubDate>
		<dc:creator><![CDATA[Janga]]></dc:creator>
				<category><![CDATA[Excelｱﾌﾟﾘｹｰｼｮﾝ操作]]></category>
		<category><![CDATA[プロパティ]]></category>
		<category><![CDATA[exeパス]]></category>
		<category><![CDATA[フルパス]]></category>

		<guid isPermaLink="false">http://excelcsharp.lance40.com/?p=158</guid>
		<description><![CDATA[Excel.exeのフォルダの完全パスを取得します。 ※操作中のファイルパスではありません、注意してください。 （32bit OSでのデフォルトはC:\Program Files\Microsoft Office…あたり [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Excel.exeのフォルダの完全パスを取得します。</p>
<p>※操作中のファイルパスではありません、注意してください。</p>
<p>（32bit OSでのデフォルトはC:\Program Files\Microsoft Office…あたりだと思います。）</p>
<pre class="brush: csharp; title: ; notranslate">
{
            // Excel操作用オブジェクト
            Microsoft.Office.Interop.Excel.Application xlApp = null;
            

            // Excelアプリケーション生成
            xlApp = new Microsoft.Office.Interop.Excel.Application();

            // ◆Exe格納パスをメッセージボックスに表示◆
            // Pathプロパティ
            System.Windows.Forms.MessageBox.Show(xlApp.Path);

            // Excelアプリケーションを解放
            xlApp.Quit();
            System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp);

 }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://excelcsharp.lance40.com/excelpath.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ExcelBook、アプリケーションを閉じる</title>
		<link>http://excelcsharp.lance40.com/closeapp.html</link>
		<comments>http://excelcsharp.lance40.com/closeapp.html#comments</comments>
		<pubDate>Sun, 24 Nov 2013 12:05:51 +0000</pubDate>
		<dc:creator><![CDATA[Janga]]></dc:creator>
				<category><![CDATA[Excelｱﾌﾟﾘｹｰｼｮﾝ操作]]></category>
		<category><![CDATA[ブック操作]]></category>
		<category><![CDATA[メソッド]]></category>
		<category><![CDATA[Closeメソッド]]></category>
		<category><![CDATA[Excel閉じる]]></category>
		<category><![CDATA[Quitメソッド]]></category>
		<category><![CDATA[ブック閉じる]]></category>

		<guid isPermaLink="false">http://excelcsharp.lance40.com/?p=144</guid>
		<description><![CDATA[Excelを閉じる処理です。 「◆Bookを閉じる◆」で、WorkBookを閉じる処理を行い、 「◆Excelアプリケーション閉じる◆」で、アプリケーションの終了処理を行っています。]]></description>
				<content:encoded><![CDATA[<p>Excelを閉じる処理です。</p>
<p>「◆Bookを閉じる◆」で、WorkBookを閉じる処理を行い、<br />
「◆Excelアプリケーション閉じる◆」で、アプリケーションの終了処理を行っています。</p>
<pre class="brush: csharp; title: ; notranslate">
{
    // Excel操作用オブジェクト
    Application xlApp = null;
    Workbooks xlBooks = null;
    Workbook xlBook = null;
    Sheets xlSheets = null;
    Worksheet xlSheet = null;

    // Excelアプリケーション生成
    xlApp = new Application();
    xlApp.DisplayAlerts = false;    // 確認メッセージを非表示に設定

    // 新規のExcelブックを開く
    xlBooks = xlApp.Workbooks;
    xlBook = xlBooks.Add();

    // シートを選択する
    xlSheets = xlBook.Worksheets;
    xlSheet = xlSheets[1] as Worksheet; // 1シート目を操作対象に設定する

    // 確認のためExcelを表示させて3秒停止
    xlApp.Visible = true;
    System.Threading.Thread.Sleep(3000);

    // ■■■以下、COMオブジェクトの解放■■■

    // Sheet解放
    System.Runtime.InteropServices.Marshal.ReleaseComObject(xlSheet);
    System.Runtime.InteropServices.Marshal.ReleaseComObject(xlSheets);

    // ◆Bookを閉じる◆
    // Closeメソッド
    xlBook.Close();
    System.Runtime.InteropServices.Marshal.ReleaseComObject(xlBook);
    System.Runtime.InteropServices.Marshal.ReleaseComObject(xlBooks);

    // アラートを元に戻す
    xlApp.DisplayAlerts = true;

    // ◆Excelアプリケーション閉じる◆
    // Quitメソッド
    xlApp.Quit();
    System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp);

}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://excelcsharp.lance40.com/closeapp.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Excelの確認メッセージを非表示に設定する（アラート設定）</title>
		<link>http://excelcsharp.lance40.com/displayalerts.html</link>
		<comments>http://excelcsharp.lance40.com/displayalerts.html#comments</comments>
		<pubDate>Sun, 24 Nov 2013 11:51:25 +0000</pubDate>
		<dc:creator><![CDATA[Janga]]></dc:creator>
				<category><![CDATA[Excelｱﾌﾟﾘｹｰｼｮﾝ操作]]></category>
		<category><![CDATA[プロパティ]]></category>
		<category><![CDATA[DisplayAlertsプロパティ]]></category>
		<category><![CDATA[アラート]]></category>
		<category><![CDATA[メッセージ非表示]]></category>

		<guid isPermaLink="false">http://excelcsharp.lance40.com/?p=141</guid>
		<description><![CDATA[操作対象のExcelアプリケーションのDisplayAlertsプロパティを取得・設定します。 DisplayAlertsにFalseを設定すると、Excelを閉じるときなどに表示されるメッセージの表示／非表示を制御でき [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>操作対象のExcelアプリケーションのDisplayAlertsプロパティを取得・設定します。</p>
<p>DisplayAlertsにFalseを設定すると、Excelを閉じるときなどに表示されるメッセージの表示／非表示を制御できます。</p>
<p>以下の処理を実行すると、表示されたExcelの編集→閉じる操作をしても保存要否の確認メッセージが表示されません。</p>
<p>逆に<strong>xlApp.DisplayAlerts</strong>にTrueを設定すると、確認メッセージが表示されるようになります。</p>
<pre class="brush: csharp; title: ; notranslate">
        {

            // Excel操作用オブジェクト
            Microsoft.Office.Interop.Excel.Application xlApp = null;
            Microsoft.Office.Interop.Excel.Workbooks xlBooks = null;
            Microsoft.Office.Interop.Excel.Workbook xlBook = null;
            Microsoft.Office.Interop.Excel.Sheets xlSheets = null;
            Microsoft.Office.Interop.Excel.Worksheet xlSheet = null;

            // Excelアプリケーション生成
            xlApp = new Microsoft.Office.Interop.Excel.Application();

            // ◆アラートメッセージ非表示設定◆
            xlApp.DisplayAlerts = false;

            // 新規のExcelブックを開く
            // Addメソッド
            xlBooks = xlApp.Workbooks;
            xlBook = xlBooks.Add();

            // シートを選択する
            xlSheets = xlBook.Worksheets;
            xlSheet = xlSheets[1] as Microsoft.Office.Interop.Excel.Worksheet; // 1シート目を操作対象に設定する

            // 表示
            xlApp.Visible = true;

            // ■■■以下、COMオブジェクトの解放■■■

            // Sheet解放
            System.Runtime.InteropServices.Marshal.ReleaseComObject(xlSheet);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(xlSheets);

            // Book解放
            //xlBook.Close();
            System.Runtime.InteropServices.Marshal.ReleaseComObject(xlBook);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(xlBooks);

            // Excelアプリケーションを解放
            //xlApp.Quit();
            System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp);


        }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://excelcsharp.lance40.com/displayalerts.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Excelのバージョンを取得する</title>
		<link>http://excelcsharp.lance40.com/version.html</link>
		<comments>http://excelcsharp.lance40.com/version.html#comments</comments>
		<pubDate>Wed, 20 Nov 2013 14:32:31 +0000</pubDate>
		<dc:creator><![CDATA[Janga]]></dc:creator>
				<category><![CDATA[Excelｱﾌﾟﾘｹｰｼｮﾝ操作]]></category>
		<category><![CDATA[プロパティ]]></category>
		<category><![CDATA[バージョン]]></category>

		<guid isPermaLink="false">http://excelcsharp.lance40.com/?p=108</guid>
		<description><![CDATA[Excelのバージョンを取得します。 このプロパティによって取得できる値は以下の通りです。 &#160; Excel バージョン 2010 14.0 2007 12.0 2003 11.0 2002 10.0 2000  [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Excelのバージョンを取得します。</p>
<p>このプロパティによって取得できる値は以下の通りです。</p>
<p>&nbsp;</p>
<table border="2" cellpadding="5">
<tbody>
<tr>
<td><strong>Excel</strong></td>
<td><strong>バージョン</strong></td>
</tr>
<tr>
<td>2010</td>
<td>14.0</td>
</tr>
<tr>
<td>2007</td>
<td>12.0</td>
</tr>
<tr>
<td>2003</td>
<td>11.0</td>
</tr>
<tr>
<td>2002</td>
<td>10.0</td>
</tr>
<tr>
<td>2000</td>
<td>9.0</td>
</tr>
<tr>
<td>97</td>
<td>8.0</td>
</tr>
</tbody>
</table>
<p>&nbsp;</p>
<p>取得方法は以下のようになります。</p>
<pre class="brush: csharp; title: ; notranslate">

 {

     // Excel操作用オブジェクト
     Application xlApp = null;

     // Excelアプリケーション生成
     xlApp = new Application();

     // ◆バージョン番号をメッセージボックスに表示◆
     // Versionプロパティ
     System.Windows.Forms.MessageBox.Show(xlApp.Version);

     // Excelアプリケーションを解放
     xlApp.Quit();
     System.Runtime.InteropServices.Marshal.ReleaseComObject(xlApp);

 }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://excelcsharp.lance40.com/version.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
