Skip to content

Instantly share code, notes, and snippets.

//form方式
<form id="uploadForm" enctype="multipart/form-data">
<input id="file" type="file" name="file"/>
<button id="upload" type="button">upload</button>
</form>
$.ajax({
url: '/upload',
type: 'POST',
cache: false,
USE [master]
GO
ALTER DATABASE students SET RECOVERY SIMPLE WITH NO_WAIT
GO
ALTER DATABASE students SET RECOVERY SIMPLE
GO
USE students
GO
--此处需要注意,并非所有数据库的日志文件名都是“数据库名_log”
DBCC SHRINKFILE (N'students_log' , 0,TRUNCATEONLY)
static void Main(string[] args)
{
IWorkbook workbook = new XSSFWorkbook();
ISheet sheet1 = workbook.CreateSheet("Sheet1");
sheet1.CreateRow(0).CreateCell(0).SetCellValue("This is a Sample");
int x = 1;
for (int i = 1; i <= 15; i++)
{
IRow row = sheet1.CreateRow(i);
for (int j = 0; j < 15; j++)
/// <summary>
/// 将excel中的数据导入到DataTable中
/// </summary>
/// <param name="sheetName">excel工作薄sheet的名称</param>
/// <param name="isFirstRowColumn">第一行是否是DataTable的列名</param>
/// <returns>返回的DataTable</returns>
public DataTable ExcelToDataTable(string sheetName, bool isFirstRowColumn)
{
ISheet sheet = null;
DataTable data = new DataTable();
/// <summary>
/// 将DataTable数据导入到excel中
/// </summary>
/// <param name="data">要导入的数据</param>
/// <param name="isColumnWritten">DataTable的列名是否要导入</param>
/// <param name="sheetName">要导入的excel的sheet的名称</param>
/// <returns>导入数据行数(包含列名那一行)</returns>
public int DataTableToExcel(DataTable data, string sheetName, bool isColumnWritten)
{
int i = 0;
public static bool ExportExcel(Page page, string FileName, string SheetName, string ContentBody)
{
try
{
string content = "<html xmlns:x=\"urn:schemas-microsoft-com:office:excel\"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>" + SheetName + "</x:Name><x:WorksheetOptions><x:Print><x:ValidPrinterInfo /></x:Print></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body>" + ContentBody + "</body></html>";
page.Response.Buffer = true;
page.Response.AppendHeader("Content-Disposition", "attachment;filename=" + FileName + DateTime.Now.ToString("yyyyMMdd") + ".xls");
page.Response.ContentEncoding = System.Text.Encoding.UTF8;
page.Response.ContentType = "application/vnd.ms-excel";
page.EnableViewState = false;
@johnsonz
johnsonz / ipcalc.go
Created August 31, 2016 03:12 — forked from kotakanbe/ipcalc.go
get all IP address from CIDR in golang
package main
import (
"net"
"os/exec"
"github.com/k0kubun/pp"
)
func Hosts(cidr string) ([]string, error) {
@johnsonz
johnsonz / go-send-mail-using-gomail
Last active July 21, 2016 01:47
使用go来发送邮件
package main
import "gopkg.in/gomail.v2"
func main() {
m := gomail.NewMessage()
m.SetHeader("From", "you@example.com")
m.SetHeader("To", "you@example.com", "you@example.com")
m.SetAddressHeader("Cc", "dan@example.com", "Dan")
@johnsonz
johnsonz / go-mssql-using-go-mssqldb
Last active January 12, 2021 07:50
使用go来连接sql server数据库
package main
import (
"database/sql"
"fmt"
"log"
_ "github.com/denisenkom/go-mssqldb"
)
@johnsonz
johnsonz / html-pop-layout
Created May 25, 2016 02:37
html弹出层,背景半透明,用于提示或确认
<div class="back" style="position: fixed !important; background-position: center center;
position: absolute; top: 0; left: 0; height: 100%; width: 100%; z-index: 999;
background: #000 no-repeat center center; opacity: 0.8; filter: alpha(opacity=80);
font-size: 14px; line-height: 20px; display: none;">
</div>
<div class="pop_winwrap" style="text-align: center; position: absolute;
top: 30%; left: 30%; margin: 20px 0 20px 0px; padding: 3px 3px 3px 10px; z-index: 1000; background:
opacity: 1.0; filter: alpha(opacity=100); display:none; ">
<img class='' id="" src="images/img.png" style="cursor: pointer;" />
</div>