Call the Excel print preview page
Public void excelprint (string strfilepath, string strsheetname) {Microsoft. office. interOP. excel. applicationclass xlapp = new applicationclass (); Microsoft. office. interOP. excel. workbooks xlworkbooks; Microsoft. office. interOP. excel. workbook xlworkbook; Microsoft. office. interOP. excel. worksheet xlworksheet; system. type tyworkbooks; system. reflection. methodinfo [] methods; object objfilepath; object OMI Ssing = system. reflection. Missing. value; strfilepath = server. mappath (strfilepath); If (! System. io. file. exists (strfilepath) {Throw new system. io. filenotfoundexception (); return;} Try {xlapp. visible = true; xlworkbooks = xlapp. workbooks; tyworkbooks = xlworkbooks. getType (); methods = tyworkbooks. getmethods (); objfilepath = strfilepath; object nothing = system. reflection. missing. value; xlworkbook = xlapp. workbooks. open (strfilepath, nothing, nothing, Nothing); // xlworkbook = (Microsoft. office. interOP. excel. workbook) tyworkbooks. invokemember ("open", // system. reflection. bindingflags. invokemethod, // null, // xlworkbooks, // new object [] {objfilepath, true, true}); xlworksheet = (Microsoft. office. interOP. excel. worksheet) xlworkbook. worksheets [strsheetname]; xlworksheet. printpreview (tr UE); xlworkbook. Close (omissing, omissing, omissing);} catch (exception ex) {Throw ex;} finally {If (xlapp! = NULL) {xlapp. Quit (); system. runtime. interopservices. Marshal. releasecomobject (xlapp); xlapp = NULL;} GC. Collect ();}}