// Display OpenFileDialog by calling ShowDialog method
Nullable<bool> result = dlg.ShowDialog();
// Get the selected file name and display in a TextBox
if (result == true)
{
string filename = dlg.FileName;
xpsFilePath = System.Environment.CurrentDirectory + "\\" + dlg.SafeFileName + ".xps";
SourceUrl.Text = filename;
SpreadsheetInfo.SetLicense("FREE-LIMITED-KEY");
ExcelFile.Load(filename).Print();
}
var convertResults = OfficeToXps.ConvertToXps(SourceUrl.Text, ref xpsFilePath);
switch (convertResults.Result)
{
case ConversionResult.OK:
xpsDoc = new System.Windows.Xps.Packaging.XpsDocument(xpsFilePath, FileAccess.ReadWrite);
documentViewer1.Document = xpsDoc.GetFixedDocumentSequence();
officeFileOpen_Status = true;
break;
case ConversionResult.InvalidFilePath:
// Handle bad file path or file missing
break;
case ConversionResult.UnexpectedError:
// This should only happen if the code is modified poorly
break;
case ConversionResult.ErrorUnableToInitializeOfficeApp:
// Handle Office 2007 (Word | Excel | PowerPoint) not installed
break;
case ConversionResult.ErrorUnableToOpenOfficeFile:
// Handle source file being locked or invalid permissions
break;
case ConversionResult.ErrorUnableToAccessOfficeInterop:
// Handle Office 2007 (Word | Excel | PowerPoint) not installed
break;
case ConversionResult.ErrorUnableToExportToXps:
// Handle Microsoft Save As PDF or XPS Add-In missing for 2007
break;
}
를 사용하지만이 오류가 (system.argumentexception 폭을 발생 높이가이 선 (ExcelFile.Load (파일 이름)에 음이 아닌 수 있어야합니다. 도움을 인쇄 파일 엑셀 내가 <strong>Excel에서</strong> 파일 인쇄 시도하고 C#을
덕분에 다음이 첨부 파일과 같은 인쇄())는 나!
는
This is Screenshot 오류 http://i.stack.imgur.com/Kg9Z8.png – Pshtiwan
이미지가 필요했기 때문에이 이미지를 추가했습니다. 코멘트가 아닙니다. 이것에 대한 간단한 대답은, 당신이 설정하고있는 너비와 높이가 무엇입니까? –