vb.net - Crystal report export in excel -
There is a problem with my crystal report, exporting Axl does anyone help me to code or a suggestion code How to get caught, the file you exported already exists For example if you have exported lotinfo then next lotinfo2 will be so lotinfo3 etc., my code is always exporting a single file and a name.
Click the private sub button 1_Click (System.Object, as ByVal Sender, System.EventArgs as ByVal E) button 1. Click
Dim CrExportOptions as export options dim CrDiskFileDestinationOptions as new _ DiskFileDestinationOptions () Dim CrFormatTypeOptions CrDiskFileDestinationOptions.DiskFileName = as new ExcelFormatOptions _ "c: \ Lot Enterprise Information.xls "Kreksportopshans = Crypt .aksportdestinashntype = Aksportdestinashntypekdiskfile .aksportformeteepe = Aksportformeteepe.aksel Kdestinashnopshans = Krdiskfiledestinashnopshans. Finished with Formetopts = CrFormatTypeOptions crypt.Export () to MessageBox.Show ( "in Czech on C:", "drive located on Enterprise Information located in Su-drive C:", "drive C:" message box button. OK, message box icon.) Hold the Expansion MSBBX ("Select specific date to convert!"). ) End end try
I have been using this function for a while I am Fix it on your usage basis.
The personal function filexists (strings, such as the volt path, string filename filename), string 'This function basically adds a counter when the file already exists' such as the filename file name (1) file name (2) integer as oval = 0 dim Orgeniylfailnam string = Sistmkaiokpathkcomben (path, filename) dim newFileName = as orginialFileName extension string = "" dim Training index = integer = 0 while file. Example (Nufailnam) counter = counter + 1 extension = Nyafailnamksbstring (Nyafailnamklistindaksof ( ".")) Filename = filename. Substring (0, filename.LastIndexOf ( ".")) TestIndex = filename.LastIndexOf ( "( ") If testIndex then substring (0, testIndex) end if newFileName = String.Format (" {0} ({1}) ", System.IO.Path.Combine (Path, file name), counter.ToString ()) file name = String.Format ("{0} ({1})", file name, counter.ToString ()) NewFileName + = extension file name + = extension end File name expiration ft to return Example: command output string output = fileExists ("C: \ test", "File.xls") MsgBox (output)
/ Code>
link can also be useful to you.
Edit:
You can try it on your try -catch
block
can use full full path as String = "C: \ fileinfo.xls" directory, output, file name as string if file. Example (full text) then directory = full path Sebstring (0, fulltext.listindex ("\") file name = full path FullPath = path.combine (directory, output) end if
then this part Change
CrDiskFileDestinationOptions.DiskFileName = _ "c: \ Lot Enterprise Information.xls"
the
CrDiskFileDestina TionOptions .DiskFileName = _ Fulltext
Comments
Post a Comment