这是一个只能创建create xls文件的代码.但我想创建xlsx(Excel)文件; 我怎么能从这段代码那里做到这一点,否则我可以用另一个代码来创建xlsx文件.
using Excel = Microsoft.Office.Interop.Excel;
using System.Runtime.InteropServices;
Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
if (xlApp == null)
{
MessageBox.Show("Excel is not properly installed!!");
return;
}
Excel.Workbook xlWorkBook;
Excel.Worksheet xlWorkSheet;
object misValue = System.Reflection.Missing.Value;
xlWorkBook = xlApp.Workbooks.Add(misValue);
xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
xlWorkSheet.Cells[1, 1] = "ID";
xlWorkSheet.Cells[1, 2] = "Name";
xlWorkSheet.Cells[2, 1] = "1";
xlWorkSheet.Cells[2, 2] = "One";
xlWorkSheet.Cells[3, 1] = "2";
xlWorkSheet.Cells[3, 2] = "Two";
xlWorkBook.SaveAs("d:\\vdfgdfg.xls", Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
xlWorkBook.Close(true, misValue, misValue);
xlApp.Quit(); …Run Code Online (Sandbox Code Playgroud) Error: Could not find or load main class org.apache.maven.surefire.booter.ForkedBooter Jenkins.
Run Code Online (Sandbox Code Playgroud)
我从jenkins构建Maven项目时遇到以下错误。
这是我的代码,我无法检索多个数据,如果我只给它一个列它可以工作,但当我给多列时,它与我使用c#和sql服务器工作.
SqlConnection con3 = new SqlConnection(conString);
con3.Open();
if (con3.State == System.Data.ConnectionState.Open)
{
string s = "SELECT ([reg_grade] ,[t_name],[start_time], [end_time]) from addteacher where class_id='" + comboBox2.SelectedItem.ToString() + "' ";
SqlCommand cm = new SqlCommand(s, con3);
SqlDataReader dr1 = cm.ExecuteReader();
while (dr1.Read())
{
grade_att.Text = (dr1["reg_grade"]).ToString();
tname_att.Text = (dr1["t_name"]).ToString();
stime.Text = (dr1["start_time"]).ToString();
etime.Text = (dr1["end_time"]).ToString();
}
}
con3.Close();
Run Code Online (Sandbox Code Playgroud)