全5件 (5件中 1-5件目)
1
private void button1_Click(object sender, EventArgs e) { //1データごとの行数 int RowCount = 7; int ColCount = 5; int StartCol1 = 2; int StartCol2 = ColCount + StartCol1; int StartCol3 = ColCount + StartCol2; Excel.Application oXls = new Excel.Application(); // Excelオブジェクト string excelName = "C:\\Users\\x300\\sample.xls"; Excel.Workbook oWBook; // workbookオブジェクト oXls.Visible = true; // 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)]; //データ取り出し(コピー) for (int i = 0; i < 100; i++) { //何行目 int DataRowNum = (int)(i / 3); //何列目 int DataColNum = (int)(i % 3); Excel.Range range1; Excel.Range range2; //コピー元 range1 = (Excel.Range)oSheet.Cells[1, StartCol1]; range2 = (Excel.Range)oSheet.Cells[1 + RowCount - 1, StartCol1 + ColCount - 1]; range1 = oSheet.get_Range(range1, range2); range1.Copy(Type.Missing); int rowstart = 0; int colstart = 0; int rowend = 0; int colend = 0; //コピー先検索 switch (DataColNum) { case 0: rowstart = DataRowNum * RowCount + 1; colstart = StartCol1; rowend = DataRowNum * RowCount + RowCount; colend = StartCol1 + ColCount - 1; break; case 1: rowstart = DataRowNum * RowCount + 1; colstart = StartCol2; rowend = DataRowNum * RowCount + RowCount; colend = StartCol2 + ColCount - 1; break; case 2: rowstart = DataRowNum * RowCount + 1; colstart = StartCol3; rowend = DataRowNum * RowCount + RowCount; colend = StartCol3 + ColCount - 1; break; default: break; } range1 = (Excel.Range)oSheet.Cells[rowstart, colstart]; range2 = (Excel.Range)oSheet.Cells[rowend, colend]; //ペースト range1 = oSheet.get_Range(range1, range2); range1.PasteSpecial(Excel.XlPasteType.xlPasteAll, Excel.XlPasteSpecialOperation.xlPasteSpecialOperationNone, false, false); //値を入れていく int c1 = 0; int r1 = 0; //名前 ((Excel.Range)oSheet.Cells[rowstart + r1, colstart + c1]).Value2 = "なまえ"; //年齢 c1 = 3; r1 = 1; ((Excel.Range)oSheet.Cells[rowstart + r1, colstart + c1]).Value2 = rowstart + r1; } //oWBook.Close(Type.Missing, Type.Missing, Type.Missing); //oXls.Quit(); } // 指定されたワークシート名のインデックスを返すメソッド 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; }
2011.05.31
![]()
ダイエットサプリでしかも激安のものを見つけましたのでご紹介いたします。セントジョーンズワート♪GABAはリラックス・リフレッシュに欠かせない成分♪それを1日2粒とし...価格:100円(税込、送料込)興味がある方は是非ご購入されてみてはいかがでしょうか。
2011.05.27
![]()
価格に訳あり!メール便送料無料ダイエットサプリメント初回限定100円 送料無料サプリメント!!...価格:100円(税込、送料込)using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;namespace WindowsFormsApplication1{ public partial class Form1 : Form { //コンストラクタ public Form1() { InitializeComponent(); } //画面ロード private void Form1_Load(object sender, EventArgs e) { //通常のボタン列を作成 DataGridViewButtonColumn dgvBtnCols = new DataGridViewButtonColumn(); //ボタン列を拡張ボタンに設定 dgvBtnCols.CellTemplate = new DataGridButtonCellEx(); this.dataGridView1.Columns.Add(dgvBtnCols); } } /****************************************************************/ //DataGridViewButtonCellの拡張クラスを作成 /****************************************************************/ public partial class DataGridButtonCellEx : DataGridViewButtonCell { protected override void Paint(Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) { base.Paint(graphics, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts); TextRenderer.DrawText(graphics, "◎", this.DataGridView.Font, cellBounds, Color.Blue); } }}
2011.05.18
![]()
座ってるだけのダイエット座布団簡単に痩せるダイエットです!!◆レビュー470件突破!◆楽天ダイエットクッションランキング1位も獲得!◆オフィスチェアでの...価格:2,500円(税込、送料込)
2011.05.15
![]()
【送料無料】トルマリンC-4セット★ローション+薬用美白ジェル「NO.3」の大人気セットです。価格:9,600円(税込、送料込)
2011.05.05
全5件 (5件中 1-5件目)
1
![]()
