【发布时间】:2019-02-11 10:21:36
【问题描述】:
它基本上是一个与Arduino连接的系统,您可以使用您的学校卡与系统链接,当您链接时您可以使用打印机或3d打印机。
数据库到 Excel 的导出已经可以工作,但导入到数据库的功能不行。
代码:
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 HTC_toestemming_systeem_V1
{
public partial class ImportFromExcel : Form
{
//doesnt work
private string openLocation;
public int columns { get; set; }
public int rows { get; set; }
public ImportFromExcel()
{
InitializeComponent();
}
private void Kies_Folder_Click(object sender, EventArgs e)
{
using (OpenFileDialog sfd = new OpenFileDialog())
{
selectFile:
sfd.Title = "Selecteer een bestand";
sfd.Filter = "Excel bestand (*.xls)|*.xls";
if (sfd.ShowDialog() == DialogResult.OK)
{
openLocation = sfd.FileName;
label1.Text = openLocation;
}
else
{
if (MessageBox.Show("Geen locatie geselecteerd!\n\nWil je alsnog een locatie selecteren ?", "Dan niet", MessageBoxButtons.RetryCancel, MessageBoxIcon.Information) == DialogResult.Retry)
{
goto selectFile;
}
return;
}
}
}
private void Lees_Excel_Click(object sender, EventArgs e)
{
//gebruikt de Excel.cs bestand
Excel_ excel = new Excel_(@openLocation, 1);
int column = excel.columns;
int row = excel.rows;
//MessageBox.Show(column + " + " + row);
//doet alles in een array
string[,] read = excel.ReadRange(1, 1, row, column);
excel.Close();
}
private void ImportFromExcel_Load(object sender, EventArgs e)
{
}
private void richTextBox1_TextChanged(object sender, EventArgs e)
{
}
}
}
【问题讨论】:
-
也许在说有问题之前先尝试实现一些东西。我认为stackoverflow.com/questions/23041021/… 是一个很好的开始方式
标签: c# excel import export printers