我有一个sql server 2008作业,用dll创建excel文件。 dll使用xmlwriter创建excel文件。 它正在创建xml电子表格2003文件
问题是文件太大了250mb
CREATE ASSEMBLY [myclr]
AUTHORIZATION [dbo]
FROM 'myclr.dll'
WITH PERMISSION_SET = unsafe;
GO
我的尝试:
使用Windows.base.dll的问题openxml无法注册到sql server,因为它不是supported dlls
客户端不想设置办公室到服务器
现在我的解决方案是我将编写一个Windows服务,它将打开并保存为excel文件。 我用microsoft.office.interop写的 但我需要另一种方法来做到这一点。
Microsoft.Office.Interop.Excel.ApplicationClass _Excel = null;
Microsoft.Office.Interop.Excel.Workbook WB = null;
// Microsoft.Office.Interop.Excel.Worksheet WS = null;
object missing = Type.Missing;
try
{
_Excel = new Microsoft.Office.Interop.Excel.ApplicationClass();
WB = _Excel.Workbooks.Open(path,
missing, missing, missing, missing,
missing, missing, missing, missing,
missing, missing, missing, missing,
missing, missing);
}
catch (Exception ex)
{
WB.Close(false, missing, missing);
throw;
}
finally
{
GC.Collect();
GC.WaitForPendingFinalizers();
_Excel.DisplayAlerts = false;
WB.SaveAs(path,
Microsoft.Office.Interop.Excel.XlFileFormat.xlExcel8,
missing, missing, missing, missing,
Microsoft.Office.Interop.Excel.
XlSaveAsAccessMode.xlNoChange,
Microsoft.Office.Interop.Excel.
XlSaveConflictResolution.xlLocalSessionChanges,
missing, missing, missing, missing);
_Excel.Quit();
}
openxml
using (SpreadsheetDocument ssd =
SpreadsheetDocument.Open("myfile.xls", true))
{
WorkbookPart wbPart = ssd.WorkbookPart;
WorksheetPart worksheetPart = wbPart.WorksheetParts.First();
worksheetPart.Worksheet.Save();
wbPart.Workbook.Save();
ssd.Close();
}
文件包含损坏的数据
注意:很长的抱歉,没有土豆