I'm using SpreadsheetLight 3.5.0 to create an Excel file which includes images. Saving the Excel causes an exception.
This code
If OpenDialog.ShowDialog() = DialogResult.OK Then
Using pDoc = New SLDocument()
Dim pSLPic = New SLPicture(OpenDialog.FileName)
pSLPic.SetPosition(1, 1)
pDoc.InsertPicture(pSLPic)
pDoc.SaveAs("test.xlsx")
End Using
End If
results in the following exception when calling pDoc.SaveAs. I can display the same image in a PictureBox or open it by double clicking in Explorer. So there should not be any problems with Windows access rights.
System.UnauthorizedAccessException: Access to the path '\\pomari.local\Pomarfin\ParYhteiset\Tuotekuvat\12006.jpg' is denied. at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode) at SpreadsheetLight.SLDocument.WriteImageParts(DrawingsPart dp) at SpreadsheetLight.SLDocument.WriteSelectedWorksheet() at SpreadsheetLight.SLDocument.CloseAndCleanUp() at SpreadsheetLight.SLDocument.SaveAs(String FileName)
The error does not occur in all environments. It doesn't matter if the filepath uses a mapped drive or UNC-path.
Do you have any suggestions what to try next?
Giving write rights to the folder containing the images resolved the problem. So it seems read rights are not enough when saving the Excel.