|
private void button6_Click(object sender, EventArgs e)
{
System.Windows.Forms.FolderBrowserDialog dialog = new System.Windows.Forms.FolderBrowserDialog();
dialog.Description = "请选择广联达导出所在文件夹";
if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK||dialog.ShowDialog() == System.Windows.Forms.DialogResult.Cancel)
{
if (string.IsNullOrEmpty(dialog.SelectedPath))
{
MessageBox.Show(this, "文件夹路径不能为空", "提示");
return;
}
}
label4.Text = "清单检查中......";
string[] files = System.IO.Directory.GetFiles(dialog.SelectedPath, "*.xls", System.IO.SearchOption.AllDirectories);
for (int i = 0; i < files.Length; i++)
{
//if (输入的文件名 == Path.GetFileName(files[i]))
{
string filepath = files[i];
exceledit.Open(filepath);
listBox1.Items.Add( filepath.Substring(filepath.LastIndexOf("\\") + 1, filepath.Length - 1 - filepath.LastIndexOf("\\")));
foreach (Worksheet ws in exceledit.myWorkBook.Worksheets)
if (ws.Name.Contains("招-表4"))
{
exceledit.ActivateSheet(ws.Name);
int rowid = 1;
while (exceledit.ReadData(rowid, 1).Trim() != "合 计")
{
int outrow;
if (int.TryParse(exceledit.ReadData(rowid, 1), out outrow))
{
if (checkBox1.Checked)
{
if (exceledit.ReadData(rowid, 4).Trim() == "")//描述为空
listBox1.Items.Add(exceledit.ReadData(rowid, 1) + "行描述为空" );
}
if (checkBox2.Checked)
{
double result;
if (double.TryParse(exceledit.ReadData(rowid, 7), out result))
{
if (result < 0.01)
listBox1.Items.Add( exceledit.ReadData(rowid, 1) + "行工程量为空" );
}
}
if (checkBox3.Checked)//价为空
{
double result;
if (double.TryParse(exceledit.ReadData(rowid, 8), out result))
{
if (result < 0.01)
listBox1.Items.Add(exceledit.ReadData(rowid, 1) + "行单价为空" );
}
}
}
rowid++;
}
}
exceledit.Close();
// ...
// filename就是你要的值
}
}
label4.Text = "请打开导出后的文件夹";
}
|
|