我正在使用此函数将数据表导出到excel中.
protected void ExportExcel(System.Data.DataTable dt)
{
if (dt == null||dt.Rows.Count==0) return;
Microsoft.Office.Interop.Excel.Application xlApp =
new Microsoft.Office.Interop.Excel.Application();
if (xlApp == null)
{
return;
}
System.Globalization.CultureInfo CurrentCI =
System.Threading.Thread.CurrentThread.CurrentCulture;
System.Threading.Thread.CurrentThread.CurrentCulture =
new System.Globalization.CultureInfo("en-US");
Microsoft.Office.Interop.Excel.Workbooks workbooks = xlApp.Workbooks;
Microsoft.Office.Interop.Excel.Workbook workbook =
workbooks.Add(Microsoft.Office.Interop.Excel.XlWBATemplate.xlWBATWorksheet);
Microsoft.Office.Interop.Excel.Worksheet worksheet =
(Microsoft.Office.Interop.Excel.Worksheet)workbook.Worksheets[1];
Microsoft.Office.Interop.Excel.Range range;
long totalCount = dt.Rows.Count;
long rowRead = 0;
float percent = 0;
for (int i = 0; i < dt.Columns.Count; i++)
{
worksheet.Cells[1, i + 1] = dt.Columns[i].ColumnName;
range = (Microsoft.Office.Interop.Excel.Range)worksheet.Cells[1, i + 1];
range.Interior.ColorIndex …Run Code Online (Sandbox Code Playgroud) 我对Objective-C比较新,我知道它是C的超集.但是当我尝试在GCC中编译这个C代码时,它给了我一个错误,我无法执行代码.
#include <stdio.h>
int main(){
int x;
printf("Input int:\n");
scanf("%d", x);
printf("%d", x);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
当我执行其他代码时,没有错误,但输出错误.注意:唯一的变化是"int*x".
#include <stdio.h>
int main(){
int *x;
printf("Input int:\n");
scanf("%d", x);
printf("%d", x);
return 0;
}
INPUT: 3
OUTPUT: 2147307520
Run Code Online (Sandbox Code Playgroud)