using Aspose.Cells;
Aspose.Cells.dll
SaveFileDialog saveFileDialog1 = new SaveFileDialog();
saveFileDialog1.Filter = "EXCEL文件(*.XLSX)|*.xlsx";
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
Aspose.Cells.Workbook workbook = new Aspose.Cells.Workbook();
workbook.Open(Application.StartupPath + @"\Model\成本汇总表.xlsx");
Worksheet workSheet = workbook.Worksheets[0];
Cells cells = workSheet.Cells;
#region 文字样式
Aspose.Cells.Style style = new Style();
style.HorizontalAlignment = TextAlignmentType.Center;//文字居中
style.VerticalAlignment = TextAlignmentType.Center;
style.Font.Name = "宋体";//文字字体
style.Font.Size = 10;
style1.SetBorder(BorderType.TopBorder, CellBorderType.Thin, Color.Black);
style1.SetBorder(BorderType.BottomBorder, CellBorderType.Thin, Color.Black);
style1.SetBorder(BorderType.LeftBorder, CellBorderType.Thin, Color.Black);
style1.SetBorder(BorderType.RightBorder, CellBorderType.Thin, Color.Black);
#endregion
//赋值
cells[rowIndex, colIndex].PutValue(OrderCode);
try
{
workbook.Save(saveFileDialog1.FileName, SaveFormat.Xlsx);
MessageBox.Show("导出成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch(Exception ex)
{
throw ex;
}
}