/// <summary> /// 导出 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ButtonX1_Click(object sender, EventArgs e) { //string qrCode = ""; //for (int j = 0; j < dataGridViewX1.Rows.Count; j++) //{ // qrCode = dataGridViewX1.Rows[j].Cells[1].Value.ToString(); // bcc.CreateQuickMark(pictureBox1, qrCode); // Image img = pictureBox1.Image; // img.Save("d:/temp/" + textBoxX2.Text + (j + 1).ToString().PadLeft(5,'0') + ".jpg"); //} SaveFileDialog saveFileDialog = new SaveFileDialog { //设置文件类型 Filter = "Excel 97-2003工作簿(*.xls)|*.xls|所有文件(*.*)|*.*", FileName = "QRCode", //设置默认文件名 RestoreDirectory = true, //保存对话框是否记忆上次打开的目录 CheckPathExists = true //检查目录 }; if (saveFileDialog.ShowDialog() == DialogResult.OK) { string strSaveFileLocation = saveFileDialog.FileName;//文件路径 DataTable2Excel.Data2Excel(dt, strSaveFileLocation); } }
private void buttonX2_Click(object sender, EventArgs e) { //受EXCEL限制,在每个条码前加上' if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { dt.Rows[i]["条码"] = "'" + dt.Rows[i]["条码"]; } } //导出EXCEL DataTable2Excel.DataToExcel(dt); }