public string GetRandomStr( int digit)
{
System.Random RndCls = new System.Random();
string s = "23456789ABCDEFGHJKLMNPQRSTUVWXYZ";
string RndStr = "";
for (int i = 1; i <= digit; i++)
{
RndStr += s.Substring(RndCls.Next(0, s.Length - 1), 1);
}
return RndStr;
}
protected void Button1_Click(object sender, EventArgs e)
{
string strxxx = "";
strxxx = GetRandomStr(123);
strxxx = strxxx.Substring(0, 6);
string strHashPassword=FormsAuthentication.HashPasswordForStoringInConfigFile(strxxx,"MD5");
}
我想通过点击70下Button1,然后让其得到的strxxx 和strHashPassword 自动写到一个excel里面,每一次点击产生的strxxx 和strHashPassword 自动组成一行,请问,这个怎么做?
我是新手,请详细点说,好吗?
20分送上,及时结帖。
{
System.Random RndCls = new System.Random();
string s = "23456789ABCDEFGHJKLMNPQRSTUVWXYZ";
string RndStr = "";
for (int i = 1; i <= digit; i++)
{
RndStr += s.Substring(RndCls.Next(0, s.Length - 1), 1);
}
return RndStr;
}
protected void Button1_Click(object sender, EventArgs e)
{
string strxxx = "";
strxxx = GetRandomStr(123);
strxxx = strxxx.Substring(0, 6);
string strHashPassword=FormsAuthentication.HashPasswordForStoringInConfigFile(strxxx,"MD5");
}
我想通过点击70下Button1,然后让其得到的strxxx 和strHashPassword 自动写到一个excel里面,每一次点击产生的strxxx 和strHashPassword 自动组成一行,请问,这个怎么做?
我是新手,请详细点说,好吗?
20分送上,及时结帖。
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Office.Interop.Excel;
using System.Data.SqlClient;
using System.Data.OleDb;
using System.Reflection;
namespace ExcelPrj
{
/// <summary>
/// Excel 系统中的主文件Excel.exe 本身就是 COM 组件,通过在.NET 项目中引用Exel.exe 文件可以实现对Excel 的功能控制
/// 与COM 组件相互操作是通过使用"包装类"(Wrapper Class) 和"代理"(Proxy) 的机制实现的.包装类使.NET 程序可以识别COM 组件提供的接口,而代理类则是提供对 COM 接口的访问
/// </summary>
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button3_Click(object sender, EventArgs e)
{
ExportTasks(Bind(), dataGridView1);
}
//如果 Excel 安装在计算机上,侧导出表格内容到 Excel
public void ExportTasks(DataSet TasksData, DataGridView TasksGridView)
{
// 定义要使用的Excel 组件接口
// 定义Application 对象,此对象表示整个Excel 程序
Microsoft.Office.Interop.Excel.Application excelApp = null ;
// 定义Workbook对象,此对象代表工作薄
Microsoft.Office.Interop.Excel.Workbook workBook;
// 定义Worksheet 对象,此对象表示Execel 中的一张工作表
Microsoft.Office.Interop.Excel.Worksheet ws=null;
//定义Range对象,此对象代表单元格区域
Microsoft.Office.Interop.Excel.Range r; int row = 1; int cell = 1;
//初始化 Application 对象 excelApp
excelApp = new Microsoft.Office.Interop.Excel.Application();
//在工作薄的第一个工作表上创建任务列表
workBook = excelApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet); ws =(Worksheet)workBook.Worksheets[1]; // 命名工作表的名称为 "Task Management"
ws.Name = "Task Management";// 这里 row .cell 是2个变量 .你来控制 这两个变量的 增量... ws.Cells[row, cell] = "你输入的第一个值
ws.Cells[row, cell+1] = "你输入的第二个值
excelApp.Visible = true;
}}