Allora ho capito che tutti i mie problemi derivano dal fatto che sono in uno usercontrol.
Ho installato e testato NPOI e riesco a creare fisicamente il file xls sul server... now ho il problema di proporlo all'utente per il download e qui sbatto le corna perchè non riesco a far partire un window.open dal codebehind dello UC.
Ci ho provato senza successo con
Page.ClientScript.RegisterClientScriptBlock
e con
Page.ClientScript.RegisterStartupScript
...e ora non so in che altro modo dirglielo.
codice:Protected Sub makexls() Dim workbook = New HSSFWorkbook() Dim nomefile As String = "Disponibilita_" & Now.ToString("yyyyMMdd_HHmmss") & ".xls" Dim sheet = workbook.CreateSheet("Disponibilità al " & Now.ToString("dd_MM_yyyy")) ' Add header labels Dim rowIndex = 0 Dim Row = sheet.CreateRow(rowIndex) Row.CreateCell(0).SetCellValue("Articolo") Row.CreateCell(1).SetCellValue("Descrizione") Row.CreateCell(2).SetCellValue("UM") Row.CreateCell(3).SetCellValue("Disponibilità") rowIndex += 1 'ciclo per aggiungere righe ....... 'salvo file locale Dim filename As String = ConfigurationManager.AppSettings("docpath") & nomefile Dim filedata As FileStream = New FileStream(filename, FileMode.Create) workbook.Write(filedata) 'pagina download Dim strcode= "window.open('/downloader.aspx?lnk=" & nomefile & "');" Page.ClientScript.RegisterStartupScript(Me.GetType(), "MyScript", strcode, True) End Sub

Rispondi quotando