|
Thank you verry mutch for your help, i do like this :
<br />
static void Main(string[] args)<br />
{<br />
ApplicationClass excelApplication = new ApplicationClass();<br />
Workbook excelWorkBook = null;<br />
<br />
<br />
<br />
string paramSourceBookPath = @"C:\2.xlsx";<br />
object paramMissing = Type.Missing;<br />
<br />
string paramExportFilePath = @"C:\test.pdf";<br />
XlFixedFormatType paramExportFormat = XlFixedFormatType.xlTypePDF;<br />
XlFixedFormatQuality paramExportQuality =<br />
XlFixedFormatQuality.xlQualityStandard;<br />
bool paramOpenAfterPublish = false;<br />
bool paramIncludeDocProps = true;<br />
bool paramIgnorePrintAreas = true;<br />
object paramFromPage = Type.Missing;<br />
object paramToPage = Type.Missing;<br />
<br />
<br />
<br />
try<br />
{<br />
excelWorkBook = excelApplication.Workbooks.Open(paramSourceBookPath,<br />
paramMissing, paramMissing, paramMissing, paramMissing,<br />
paramMissing, paramMissing, paramMissing, paramMissing,<br />
paramMissing, paramMissing, paramMissing, paramMissing,<br />
paramMissing, paramMissing);<br />
<br />
if (excelWorkBook != null)<br />
excelWorkBook.ExportAsFixedFormat(paramExportFormat,<br />
paramExportFilePath, paramExportQuality,<br />
paramIncludeDocProps, paramIgnorePrintAreas, paramFromPage,<br />
paramToPage, paramOpenAfterPublish,<br />
paramMissing);<br />
}<br />
catch (Exception ex)<br />
{<br />
Console.WriteLine(ex.ToString());<br />
}<br />
finally<br />
{<br />
if (excelWorkBook != null)<br />
{<br />
excelWorkBook.Close(false, paramMissing, paramMissing);<br />
excelWorkBook = null;<br />
}<br />
<br />
if (excelApplication != null)<br />
{<br />
excelApplication.Quit();<br />
excelApplication = null;<br />
}<br />
<br />
GC.Collect();<br />
GC.WaitForPendingFinalizers();<br />
GC.Collect();<br />
GC.WaitForPendingFinalizers();<br />
} <br />
<br />
<br />
}<br />
But unfortunately, it doesn't work, help me please, thank you verry mutch.
|
|
|
|
|
|
the error was:
System.ArgumentException: The value is not within the range expected.
à Microsoft.Office.Interop.Excel.WorkbookClass.ExportAsFixedFormat(XlFixedFormatType Type, Object Filename, Object Quality, Object IncludeDocProperties, Object IgnorePrintAreas, Object From, Object To, Object OpenAfterPublish, Object FixedFormatExtClassPtr)
à Excel_to_Pdf.Form1.Form1_Load(Object sender, EventArgs e) dans C:\Documents and Settings\Administrateur\Mes documents\Visual Studio 2005\Projects\Excel_to_Pdf\Excel_to_Pdf\Form1.cs:ligne 53.
Thank you verry mutch
|
|
|
|
|
|
thank you verry mutch,it work for a xlsx file,but unfortunatelly not for xsl file, how i can resolve this problem? thank you verry mutch.
|
|
|
|
|
I tried your code with a xls file and it appears to work. It was an xls made with Excel 2007, though...
As usual, what is the error?
|
|
|
|
|
the error was :
System.Runtime.InteropServices.COMException (0x800A03EC): Exception de HRESULT : 0x800A03EC
à Microsoft.Office.Interop.Excel.WorkbookClass.ExportAsFixedFormat(XlFixedFormatType Type, Object Filename, Object Quality, Object IncludeDocProperties, Object IgnorePrintAreas, Object From, Object To, Object OpenAfterPublish, Object FixedFormatExtClassPtr)
à Excel_to_Pdf.Form1.Form1_Load(Object sender, EventArgs e) dans C:\Documents and Settings\Administrateur\Mes documents\Visual Studio 2005\Projects\Excel_to_Pdf\Excel_to_Pdf\Form1.cs:ligne 68
Thnak you verry mutch.
|
|
|
|
|
No clue, sorry.
Try to search the error "System.Runtime.InteropServices.COMException (0x800A03EC): Exception from HRESULT : 0x800A03EC" in Google, hopefully someone already encountered (and solved) this error.
|
|
|
|
|
I don't find the solution, i think that it must be transformed on XSLX, but how we can transform xsl to xslx with c#? thank you verry mutch.
|
|
|
|
|
As I said, in my machine your code worked with an XSL, so maybe the problem is related to the document you are using.
Anyway, you can save an XLSX as XLS by using the SaveAs method on the workbook object and specifying XlFileFormat.xlWorkbookNormal as file format.
|
|
|
|
|
i make this?
excelWorkBook.ExportAsFixedFormat(paramExportFormat,<br />
paramExportFilePath, paramExportQuality,<br />
paramIncludeDocProps, paramIgnorePrintAreas, paramFromPage,<br />
paramToPage, paramOpenAfterPublish,<br />
XlFileFormat.xlWorkbookNormal);
but i does not work, help me please, thank you verry mutch.
|
|
|
|
|
i have often this error on message box :
Document not saved. The document may be open or an error occurred while recording.
in this code :
<br />
if (excelWorkBook != null)<br />
excelWorkBook.ExportAsFixedFormat(paramExportFormat,<br />
paramExportFilePath, paramExportQuality,<br />
paramIncludeDocProps, paramIgnorePrintAreas, paramFromPage,<br />
paramToPage, paramOpenAfterPublish,<br />
paramMissing);<br />
I am sur that the file was not open,
thank you verry mutch.
|
|
|
|
|
thank you verry mutch, so can i apply this code for a word file??
|
|
|
|
|
Hi
I have console application that contain sub project define as dll,
I would like to add XML to the dll so the when I deliver the dll it already contain the xml without sending dll and xml separately
How can I add it?
Should I just select add item and then select the XML file?
Thanks
Ronen
|
|
|
|
|
Add it as a linked resource to the dll which you are sending.
In Visual studio you can easily add a linked resource by going to project properties / Resources button. Click on the top first dropsown button to change ti to files and then you can easily add.
|
|
|
|
|
Hi All,
I am currently trying to figure out how the [assembly: AssemblyVersion("1.0.0.*")] works. In particular the * part of it. I understand about the Major Number, Minor Number and Build Number. What I don't understand is the Revision Number.
As it is * it automatically increments... however; what determines the revision number. I.e. where does it come from?
If anyone knows, I'd appreciate your thoughts,
Thanks
|
|
|
|
|
It is nothing but the number of Build action. I suppose.
|
|
|
|
|
This is also what i expected... however; I dont understand how it is generated.
For example, the application i am currently working on requires it to be displayed.
I ran the appplication and the number that was displayed was 1.2.0.19976, I made a couple of changes and ran it again, then the new version number was 1.2.0.20068. I don't understand why it increments so much.
|
|
|
|
|
Check how many time you hit F5, Build , Rebuild or Batch Build between the first and second run.
|
|
|
|
|
|
|
oh.. Great.. Thanks Giorgi
|
|
|
|
|
You are welcome
|
|
|
|
|
hi everyone;
yesterday, i fond a exciting example about topic sound recording using C#, then i had download that sample. however, when i run that program, C# said something is missing, so it can start.
when i checked, C# just know such code like Microsoft.win32; .internal; .VisualBasic ; .CSharp; .SqlServer; no .DirectX
please help me. Thank you for helping me, or anyway, reading that message
|
|
|
|
|
Perhaps you don't have the necessary dll added to references list.
|
|
|
|
|