Visualizzazione dei risultati da 1 a 10 su 39

Discussione: Problema export excel

Hybrid View

  1. #1
    Utente di HTML.it
    Registrato dal
    Jan 2010
    Messaggi
    31

    Problema export excel

    Buongiorno a tutti,

    sto cercando di creare una piccola applicazione asp che mi consenta di andare a scrivere, nelle celle e fogli che desidero, all' interno di un file excel.

    Sui vari forum ho trovato di tutto per esportare dati in excel ma ho trovato poca roba in merito alla scrittura "guidata"...

    L' unico codice a mio avviso interessante è quello che vi posterò ma genera il seguente errore:

    Microsoft Excel error '800a03ec'

    Errore nel metodo SaveAs per la classe Workbook.

    /asp_format_style.asp, riga 138


    Qualcuno più esperto di me sa come risolvere questo problema? ecco il codice trovato, grazie mille per l' aiuto!


    <%Option Explicit%>
    <html>
    <head>
    <title>ShotDev.Com Tutorial</title>
    </head>
    <body>
    <%
    Dim xlApp,xlBook,xlSheet1,FileName
    Dim Fso,MyFile
    FileName = "MyXls/MyExcel.xls"

    '*** Create Excel.Application ***'
    Set xlApp = Server.CreateObject("Excel.Application")
    Set xlBook = xlApp.Workbooks.Add

    '*** Create Sheet 1 ***'
    xlBook.Worksheets(1).Name = "My Sheet1"
    xlBook.Worksheets(1).Select

    '*** Width & Height (A1:A1) ***'
    With xlApp.ActiveSheet.Range("A1:A1")
    .ColumnWidth = 40.0
    .RowHeight = 25.0
    End With

    '*** Write text to Row 1 Column 1 ***'
    With xlApp.ActiveSheet.Cells(1,1)
    .Value = "ShotDev.Com "
    .Font.Name = "Tahoma"
    .Font.Bold = True
    .VerticalAlignment = -4108 '*** Center Rows ***'
    .HorizontalAlignment = -4108 '*** Center Column ***'
    .Font.Size = 12
    End With

    '*** Width & Height (A1:B1) ***'
    With xlApp.ActiveSheet.Range("A1:B1")
    End With

    '*** Write text to Row 1 Column 2 ***'
    With xlApp.ActiveSheet.Cells(1,2)
    .Value = "Mr.Weerachai Nukitram "
    .Font.Name = "Tahoma"
    .Font.Size = 20
    End With

    '*** Width & Height (A2:A2) ***'
    With xlApp.ActiveSheet.Range("A2:A2")
    .BORDERS.Weight = 1 '*** Border ***'
    End With

    '*** Write text to Row 1 Column 2 ***'
    With xlApp.ActiveSheet.Cells(2,1)
    .Value = "I Love ShotDev.Com "
    .Font.Name = "Tahoma"
    .Font.Size = 10
    .HorizontalAlignment = 4
    End With

    '*** Width & Height (A33) ***'
    With xlApp.ActiveSheet.Range("A33")
    .BORDERS.Color = RGB(0, 0, 0) '*** Border Color ***'
    .BORDERS.Weight = 1 '*** Border ***'
    .MergeCells = True '*** Merge Cells ***'
    End With

    '*** Write text to Row 1 Column 2 ***'
    With xlApp.ActiveSheet.Cells(3,1)
    .Value = "I Love My Live"
    .Font.Name = "Tahoma"
    .Font.Size = 10
    .HorizontalAlignment = -4108
    .Interior.ColorIndex = 44 '*** Background Color ***'
    End With

    '*** Write text to Row 4 Column 5 ***'
    With xlApp.ActiveSheet.Cells(4,5)
    .Value = "My Life"
    .Font.Name = "Tahoma"
    .Font.Size = 10
    .Font.Italic = True
    .Font.ColorIndex = 4
    .EntireColumn.AutoFit '*** AutoFit Column ***'
    End With

    '*** Write text to Row 5 Column 5 ***'
    With xlApp.ActiveSheet.Cells(5,5)
    .Value = "My Life"
    .Font.Name = "Tahoma"
    .Font.Size = 10
    .Font.Italic = True
    .Font.ColorIndex = 4
    .HorizontalAlignment = -4152 '*** Text align Right ***'
    .EntireColumn.AutoFit '*** AutoFit Column ***'
    End With

    '*** Write text to Row 6 Column 1 ***'
    With xlApp.ActiveSheet.Cells(6,1)
    .Value = "Version 2010"
    .Font.Name = "Tahoma"
    .Font.Size = 10
    .Font.ColorIndex = 4
    .Characters(8, 12).Font.Bold = True
    End With


    '** SheetType
    'xlChart = -4109;
    'xlWorksheet = -4167;
    '** WBATemplate
    'xlWBATWorksheet = -4167;
    'xlWBATChart = -4109;
    '** Page Setup
    'xlPortrait = 1;
    'xlLandscape = 2;
    'xlPaperA4 = 9;
    '** Format Cells
    'xlBottom = -4107;
    'xlLeft = -4131;
    'xlRight = -4152;
    'xlTop = -4160;
    '** Text Alignment
    'xlHAlignCenter = -4108;
    'xlVAlignCenter = -4108;
    '** Cell Borders
    'xlThick = 4;
    'xlThin = 2;

    '*** If Files Already Exist Delete files ***'
    Set Fso = CreateObject("Scripting.FileSystemObject")
    If (Fso.FileExists(Server.MapPath(FileName))) Then
    Set MyFile = Fso.GetFile(Server.MapPath(FileName))
    MyFile.Delete
    End If

    '*** Save Excel ***'
    'xlBook.PrintOut 1 '*** Print to printer ***'
    xlBook.SaveAs Server.MapPath(FileName)
    xlApp.Application.Quit

    '*** Quit and Clear Object ***'
    Set xlSheet1 = Nothing
    Set xlBook = Nothing
    Set xlApp = Nothing
    %>
    Excel Created Click here to Download.
    </body>
    </html>

  2. #2
    Utente di HTML.it L'avatar di rby
    Registrato dal
    Feb 2010
    Messaggi
    65

    Vorrei creare dei veri fogli Excel !

    Lavoro in ASP Classico e sono diversi anni che creo fogli Excel, ma in realtà sono fogli HTML.
    Avevo provato inizialmente a crearli direttamente utilizzano le istruzioni stile VB ma ho desistito.
    Ci sto riprovando ora per avere fogli più snelli ma non ci riesco.
    Ho notato che lo stesso foglio convertito da HTML ad Excel puro passa da diversi MB a pochi KB.
    Il codice di esempio che ho usato è il seguente :

    codice:
    <% Language=VBScript %>
    <%
    Set ExcelApp = CreateObject("Excel.Application")
    ExcelApp.Visible = false
    ExcelApp.Workbooks.Add
    ExcelApp.Workbooks(1).ActiveSheet.Name = "Foglio_1"
    ExcelApp.Workbooks(1).ActiveSheet.ColumnHeadings(1).Caption = "Codice Prodotto"
    ExcelApp.Workbooks(1).ActiveSheet.ColumnHeadings(2).Caption = "Descrizione"
    Set ExcelBook = ExcelApp.ActiveSheet
    ExcelApp.ActiveWorkbook.SaveAs(Server.MapPath("/ProvaSalva.xls"))
    ExcelApp.Quit
    Set ExcelApp = Nothing
    Set ExExcelBook = Nothing
    %>
    E finisce in errore quasi subito alla riga in cui cerco di creare nell'applicazione Excel l'area di lavoro ExcelApp.Workbooks.Add dicendo :
    Microsoft Office Excel:
    • Memoria o spazio su disco insufficiente. Impossibile aprire o salvare ulteriori documenti.
    • Per aumentare la memoria disponibile, chiudere le cartelle di lavoro o i programmi non necessari.
    • Per rendere disponibile spazio su disco eliminare i file non necessari.
    Ma in realtà credo che dipenda dalla impossibilità di creare l'area di lavoro probabilmente per le autorizzazioni insufficienti.
    Qualcuno mi sa aiutare ??

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.