大家好,又见面了,我是全栈君。



using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using System.IO;


namespace 教务管理系统


class DGVToExcel


public
void SaveAs(DataTable dt)
//另存新档按钮 导出成Excel


try


new SaveFileDialog();

“Execl files (*.xls)|*.xls”;


true;

true;

“导出Excel到”;

if(saveFileDialog.ShowDialog()==DialogResult.OK)




new StreamWriter(myStream, System.Text.Encoding.GetEncoding(-0));

string str = “”;

try


//写标题




//写内容

for (
int j = 0; j < dt.Rows.Count; j++)


string tempStr = “”;

for (
int k = 0; k < dt.Columns.Count; k++)


if (k > 0)


“\t”;









catch




finally







catch






发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/108014.html原文链接:https://javaforall.net