Ne na tomdle mi to chybu nehází
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;
using System.IO;
namespace Exporter
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
//Globální proměnné pro import a export dat
public String _file1; //In .xls
public String _file2; //In .xls
public String _file3; //Out .csv
public Microsoft.Office.Interop.Excel.Application xls1;
public Microsoft.Office.Interop.Excel.Application xls2;
private void xlsFile1_Click(object sender, EventArgs e)
{
//Vyvoláme první Dialog pro výběr souboru
DialogResult result = File1.ShowDialog();
_file1 = File1.FileName;
addLog("Vybrán soubor:" + _file1);
}
private void xlsFile2_Click(object sender, EventArgs e)
{
//Vyvoláme druhý Dialog pro výběr souboru
DialogResult result = File2.ShowDialog();
_file2 = File2.FileName;
addLog("Vybrán soubor:" + _file2);
}
public void addLog(String txt)
{
log.Text = txt + "\n" + log.Text;
}
private void button1_Click(object sender, EventArgs e)
{
//Vyvoláme třetí Dialog pro výběr souboru
//Začneme s Importem / Exportem samotných dat
DialogResult result = File3.ShowDialog();
_file3 = File3.FileName;
addLog("Ukládám do:" + _file3);
Microsoft.Office.Interop.Excel.Workbook workBook1 = new Microsoft.Office.Interop.Excel.Workbook();
workBook1 = xls1.Workbooks.Open(_file1, 0, true,
5, "", "", true,
Microsoft.Office.Interop.Excel.XlPlatform.xlWindows,
"\t", false, false, 0, true, 1, 0);
Microsoft.Office.Interop.Excel.Workbook workBook2 = xls2.Workbooks.Open(_file2, 0, true,
5, "", "", true,
Microsoft.Office.Interop.Excel.XlPlatform.xlWindows,
"\t", false, false, 0, true, 1, 0);
Microsoft.Office.Interop.Excel.Worksheet workSheet1 = (Microsoft.Office.Interop.Excel.Worksheet)workBook1.Sheets[1];
Microsoft.Office.Interop.Excel.Worksheet workSheet2 = (Microsoft.Office.Interop.Excel.Worksheet)workBook2.Sheets[1];
object radek = 1;
object sloupec = 1;
Boolean quit = false;
String get;
while (!quit) {
get = ((Microsoft.Office.Interop.Excel.Range)workSheet1.Cells[radek, sloupec]).Value2.ToString();
quit = true;
}
}
}
}