質問者
htmlのテーブルをDataGridViewに簡単に取り込む方法はありませんか?

質問
-
htmlのテーブルをDataGridViewに簡単に取り込む方法はありませんか?
エクセルだと一撃でセルに簡単に取り込めますが、何かそういう感じで取り込めませんか?<table cellspacing="0" summary="出走履歴" class="contentsTable"> <thead class="horseHistory "> <tr> <th scope="col" class="date">日付</th> <th scope="col" class="track">競馬場</th> <th scope="col" class="race">R</th> <th scope="col" class="name">レース名</th> <th scope="col" class="distance">距離</th> <th scope="col" class="state">馬場<br>天候</th> <th scope="col" class="number">馬番</th> <th scope="col" class="popular">人気</th> <th scope="col" class="order">着順</th> <th scope="col" class="time">タイム</th> <th scope="col" class="difference">差</th> <th scope="col" class="spurt">上3F</th> <th scope="col" class="weight">馬<br>体重</th> <th scope="col" class="jockey">騎手</th> <th scope="col" class="tax">負担重量</th> <th scope="col" class="tamer">調教師</th> </tr> </thead> <tbody class="horseHistory "> <tr class=" "> <td>2020/02/21</td> <td>笠松</td> <td>7</td> <td class="name">サラ系B6・C3組B6C3</td> <td>ダ1400</td> <td>良<br>晴</td> <td>1</td> <td>5</td> <td>1/8</td> <td>1:29.0</td> <td>0.1</td> <td>39.1</td> <td>483</td> <td>渡邊竜</td> <td>56.0</td> <td>笹野博</td> </tr> <tr class=" even"> <td>2020/02/07</td> <td>笠松</td> <td>7</td> <td class="name">サラ系B6・C3組B6C3</td> <td>ダ1400</td> <td>良<br>晴</td> <td>3</td> <td>2</td> <td>6/8</td> <td>1:29.0</td> <td>0.9</td> <td>37.9</td> <td>475</td> <td>水野翔</td> <td>56.0</td> <td>笹野博</td> </tr> <tr class=" "> <td>2020/01/24</td> <td>笠松</td> <td>5</td> <td class="name">誕生日記念50124C4</td> <td>ダ1400</td> <td>稍重<br>曇</td> <td>6</td> <td>4</td> <td>2/9</td> <td>1:29.7</td> <td>0.2</td> <td>38.3</td> <td>479</td> <td>渡邊竜</td> <td>56.0</td> <td>笹野博</td> </tr> </tbody> </table>
こんな感じのテーブルが、table1.htmlというファイルに保存されているとします。- 編集済み custardpudding 2020年2月24日 5:44
すべての返信
-
Excelのデータインポートで「Webから」の機能で、htmlファイルを読み込むようにということですよね?
ネットを検索するといくつかコードが見つかりますが、こういうことでしょうか?
HTML Table Code To Datagridview
https://stackoverflow.com/questions/37247580/html-table-code-to-datagridviewHTML <table> to DataGridView DataSource
http://www.vbforums.com/showthread.php?768627-HTML-lt-table-gt-to-DataGridView-DataSourceAdding HTML table to datagridview using HTML Agility pack
https://stackoverflow.com/questions/42471933/adding-html-table-to-datagridview-using-html-agility-pack/42472107#42472107
★良い回答には質問者は回答済みマークを、閲覧者は投票を!
- 回答の候補に設定 kumo-msftMicrosoft contingent staff, Moderator 2020年3月3日 2:45
-
custardpuddingさん、こんにちは。フォーラムオペレーターのクモです。
MSDNフォーラムにご投稿くださいましてありがとうございます。
NugetでHtmlAgilityPackをダウンロードすることができます。
https://www.nuget.org/packages/HtmlAgilityPack/どうぞよろしくお願いいたします。
MSDN/ TechNet Community Support Kumo ~参考になった投稿には「回答としてマーク」をご設定ください。なかった場合は「回答としてマークされていない」も設定できます。同じ問題で後から参照した方が、情報を見つけやすくなりますので、 ご協力くださいますようお願いいたします。また、MSDNサポートに賛辞や苦情がある場合は、MSDNFSF@microsoft.comまでお気軽にお問い合わせください。~