I am developing a C#/ASP.NET Web project at VS 2010 and it uses Crystal Reports (2008) version 12.3.0.601. Project calls the report and exports it as pdf. Anytime I change something at report design, "Memory Full" error shows up at when page is refreshed. Sometimes it does not give the error, but sometimes i try not to get the error for hours.
I have searched many sites related to the title but had no luck with a solution.
Has anyone ever encountered such error before?
System.Runtime.InteropServices.COMException (0x80041004): Memory full. Failed to export the report. Not enough memory for operation.
Thanks for your help.
For exporting to pdf I recommend you download some pdf printer ie. http://www.cutepdf.com/products/cutepdf/writer.asp
Then you can "print" the report to pdf no problems.
Hope it helps!
I had a similar problem. On my report there are some texts and images. I have read that Crystal Report first converts the JPG, PNG, etc images to BMPs then it shows the report. And converting other image type to BMP consumes much memory. First I tried to convert JPG images to BMP images in my database but then my database became bigger and bigger. Finally I found the solution (thanks to this answer).
Instead of trying to export all pages to PDF file I splitted files, zipped them and download the zip file:
Dim exportOpts As ExportOptions = New ExportOptions()
Dim pdfRtfWordOpts As PdfRtfWordFormatOptions = ExportOptions.CreatePdfRtfWordFormatOptions()
Dim destinationOpts As DiskFileDestinationOptions = ExportOptions.CreateDiskFileDestinationOptions()
Dim intPageCount As Integer = crReportDocument.FormatEngine.GetLastPageNumber(New CrystalDecisions.Shared.ReportPageRequestContext)
Dim pagecount As Integer
pagecount = Int(intPageCount / 100) + 1
Dim sonsayfa As Integer
Dim ilksayfa As Integer
Dim Anadosyaadi As String
Dim foldername As String
Dim foldernameMap As String
Anadosyaadi = Now.ToString("yyyy-MM-dd-hh-mm-ss")
foldername = "C:\inetpub\wwwroot\" + Anadosyaadi
foldernameMap = "./" + Anadosyaadi
If Not Directory.Exists(foldername) Then
Directory.CreateDirectory(foldername)
End If
For li_count As Integer = 1 To pagecount
ilksayfa = (li_count - 1) * 100 + 1
pdfRtfWordOpts.FirstPageNumber = ilksayfa
sonsayfa = li_count * 100
If sonsayfa > intPageCount Then sonsayfa = intPageCount
pdfRtfWordOpts.LastPageNumber = sonsayfa
pdfRtfWordOpts.UsePageRange = True
exportOpts.ExportFormatOptions = pdfRtfWordOpts
exportOpts.ExportFormatType = ExportFormatType.PortableDocFormat
destinationOpts.DiskFileName = foldername + "\" + li_count.ToString + ".pdf"
exportOpts.ExportDestinationOptions = destinationOpts
exportOpts.ExportDestinationType = ExportDestinationType.DiskFile
crReportDocument.Export(exportOpts)
Next
Using zip As ZipFile = New ZipFile
zip.AddDirectory(foldername)
zip.Save(foldername + "\" + Anadosyaadi + ".zip")
End Using
Response.Redirect(foldernameMap + "/" + Anadosyaadi + ".zip")
PS1: I used Ionic.Zip to zip the files. You should add
Imports Ionic.Zip
on top of your source.
PS2: When I restart the server, without doing anything else, I can get 500 pages of PDF from page number 1 to 500. At this time, I think, Crystal Reports uses some memory. Then if I want to get the second 500 pages (I mean from page number 501 to 1000), I see memory full error. Then I can get 300 pages (from 501 to 800). Then another memory full problem and I can get from 801 to 900, etc. That's why I preferred to split 100 pages. Maybe you can change it to another number.
Related
I'm trying to build a model of a factory using the personal learning edition of AnyLogic. Since this version has a limited number of blocks per model, building the full factory on a single model is presenting itself as an impossible task. In order to surpass this issue I want to split the factorys main processes into different models, which means I'll have to feed the output of process A into the input of process B.
My question is: how can I export a time stamped output of a model into the input of a different model?
Thank you in advance.
You have 2 options
Option 1: Through an Excel file (or txt file)
Simply link an Excel file in your model, using the object from the connectivity palette
Then you can get the data using code similar to below
int excelRow = 2;
String sheetName = "Sheet1!";
String cellName = sheetName + "A" + excelRow;
while (excelFile.cellExists( cellName )) {
int x = (int)excelFile.getCellNumericValue( sheetName + "A" + excelRow);
int b = (int)excelFile.getCellNumericValue( sheetName + "B" + excelRow);
int c = (int)excelFile.getCellNumericValue( sheetName + "C" + excelRow);
boolean d = excelFile.getCellBooleanValue( sheetName + "D" + excelRow);
excelRow ++; // Increase the row that we will lookup in the Excel
}
Just a while loop where you go from one excel line to the next as long as the line exists, and then do what ever is needed with the data
Option 2: AnyLogic Internal DB
Simply import your excel sheet to the AnyLogic DB and then loop over the entries in the table using a for loop
List<Tuple> rows = selectFrom(db_table).list();
for (Tuple row : rows) {
traceln(
row.get( db_table.db_column )
);
}
I have zero coding experience and am new to VBA, so I don’t even know basics, but giving it a shot. I have a Workbook, with multiple sheet in it. The one that I care about are 2 sheets called DG, and Asp. DG has a button that grabs raw data from a server and populates the sheets ( multiple date columns with data value in adjacent cells). Asp has a button that grabs data as well but on a 30-day avg so every day in a month (columns A in Asp). This is the same case with DG sheet, but DG has data from different dates in a month, because it is not a 30 day pull. So that sets an image for you, now what I want to do is create a button, with a code that can go through a date column in DG and match it with a date from asp date and if there is a match, then copy and paste the adjacent cells values in DG to asp.
This is what I have so far with searches on the internet, showing just a vlookup for a single columns I want filled out in Asp, but its not working
Private Sub CommandButton2_Click()
Dim results As Double
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim lrow As Long
Dim i As Long
Set ws1 = Worksheets("DG")
Set ws2 = Worksheets("Asp")
lrow = Worksheets("Asp").Range("A5", ws2.Range("A5").End(xlUp)).Rows.Count
For i = 5 To lrow
On Error Resume Next
result = Application.WorksheetFunction.VLookup((ws2.Range("A5" & i)), (ws1.Range("A11:B200")), 2, True)
ws2.Range("AG5").Value = result
If Err.Number = 0 Then
End If
On Error GoTo 0
Next i
End Sub
DG [1]: https://i.stack.imgur.com/ZrwfZ.jpg
ASP [2]: https://i.stack.imgur.com/tTsl0.jpg
It's Friday, Here you go, something to look at and study.
I am sorry I didn't use Vlookup, I have spent too much time chasing ghosts with that.
Perhaps others have had better success, I think what I don't like is Vlookup if it fails an exact match sometimes it chooses an adjacent row and throws everything into turmoil.
Here it is:
Option Explicit
Private Sub CommandButton2_Click()
Dim ws1 As Worksheet
Dim ws2 As Worksheet
Dim lrow2 As Long
Dim lrow1 As Long
Dim firstDataRow As Double
Dim matchRange As Range
Dim matchRow As Long
Dim i As Long
'Set up your Worksheet variables
Set ws1 = ThisWorkbook.Worksheets("DG")
Set ws2 = ThisWorkbook.Worksheets("Asp")
'You used A5 several times, so I will assume dates are in Col A and start at row 5
'Set your row with first data, maybe you need two, if they are the same on both sheets you don't
firstDataRow = 5
'find the last row on each sheet, using column A, the date col
lrow1 = ws1.Cells(ws1.Rows.Count, "A").End(xlUp).Row
lrow2 = ws2.Cells(ws2.Rows.Count, "A").End(xlUp).Row
'In your mind you now have two data ranges, one for each sheet, rows 5-last dat rows
'Pick one sheet, the one with less dates would be more efficient, you mention DG has less
'So this might be built backwards from what you are thinking, since we are iterating each row in the col
'You want to use the shrter call, IF you know its shorter (your comments)
'Loop through each row trying to find a match on your other sheet
For i = firstDataRow To lrow1
If ws1.Cells(i, "A") <> "" Then 'Test for empty
'Here is the premise of Find/Match over Vlookup
Set matchRange = ws2.Range("A" & firstDataRow & ":A" & lrow2).Find(ws1.Cells(i, "A"))
On Error Resume Next
matchRow = matchRange.Row 'Returns row number or nothing
If (Not matchRange Is Nothing) Then
'we have a row number matched on Asp, for our search item on DG
'perform the "Copy", this can be done differently but here I am going to introduce you to a way
'that can later be used with offsets and col #s, so that you may skip columns, data is not always adjacent
ws2.Cells(matchRow, "E") = ws1.Cells(i, "B")
ws2.Cells(matchRow, "F") = ws1.Cells(i, "C")
ws2.Cells(matchRow, "G") = ws1.Cells(i, "D")
Else 'DO NOTHING
End If
Else 'DO NOTHING
End If
Next i
MsgBox "Search and Copy is complete.", vbInformation, "Completed"
End Sub
There is so much more to talk about in even this simple project to make this more bullet proof. But this is a good start for where you are at.
Cheers! Happy Coding! - WWC
My code below is lost when opening PDF file which has only one column on the front page and more than 1 column on other pages.
Someone can tell me what I'm doing wrong?
Below my code:
PdfReader pdfreader = new PdfReader(pathNmArq);
ITextExtractionStrategy strategy = new SimpleTextExtractionStrategy();
for (int page=1; page <= lastPage; page++)
{
extractText = PdfTextExtractor.GetTextFromPage(pdfreader, page, strategy);
extractText = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(extractText)));
/ / ...
}
You use the SimpleTextExtractionStrategy. This strategy assumes that the text drawing instructions in the PDF are sorted by the reading order. In your case that does not seem to be the case.
If you cannot count on the PDF containing drawing operations in reading order but are only using iText text extraction strategies from the distribution, you have to know areas which constitute a single column. If a page contains multiple columns, you have to use RegionTextRenderFilter to restrict to a column and then use the LocationTextExtractionStrategy.
PS: What exactly is your intention in that
extractText = Encoding.UTF8.GetString(ASCIIEncoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(extractText)));
line?
I'm using vb net 2005. I have created a .xsd dataset with one table and a rpt report.
the dataset is PedidosDataImpresion.xsd with the table DatosPedido.
The rpt form is pedidoimpreso.rpt
this is my code:
Dim DatosImpresion As New PedidosDataImpresion
Dim TablaPrincipal As DataTable = DatosImpresion.DatosPedido
I = 0
TablaPrincipal.Rows.Add(1)
TablaPrincipal.Rows(I).Item("razonsocial") = Me.lblfacturacion.Text
TablaPrincipal.Rows(I).Item("calle") = Me.LblDireccion.Text
TablaPrincipal.Rows(I).Item("colonia") = Me.LblColonia.Text
TablaPrincipal.Rows(I).Item("ciudad") = Me.LblCiudad.Text
TablaPrincipal.Rows(I).Item("estado") = Me.LblEdo.Text
TablaPrincipal.Rows(I).Item("cp") = Me.LblEdo.Text
TablaPrincipal.Rows(I).Item("rfc") = Me.LblRfc.Text
PedidoImpreso.SetDataSource(DatosImpresion)
PedidoImpreso.PrintOptions.PrinterName = Impresora
PedidoImpreso.PrintToPrinter(Copias, True, 1, 1)
i wish to print directly to the printer with no reportviewer first
and the report comes with no data. Can you help me ?
You had to use some third party tool to do it.
What you can do is:
Make a HTML table
Fill Data
Print table on page load (using jQuery)
In case you want report format then you will need report viewer to get itself rendered.
I have a report that should read values from 2 dataset by Currency:
Dataset1: Production Total
Dataset2: Net Total
Ive tried to use:
Lookup(Fields!Currency_Type.Value,
Fields!Currency_Type1.Value,
Fields!Gross_Premium_Amount.Value,
"DataSet2")
This returns only the first amount from dataset 2.
I've tried Lookupset function as well but it didn't SUM the retrieved values.
Any help would be appreciated.
Thanks Jamie for the reply.
THis is what i have done and it worked perfect:
From Report Properties--> Code , write the below function:
Function SumLookup(ByVal items As Object()) As Decimal
If items Is Nothing Then
Return Nothing
End If
Dim suma As Decimal = New Decimal()
Dim ct as Integer = New Integer()
suma = 0
ct = 0
For Each item As Object In items
suma += Convert.ToDecimal(item)
Next
If (ct = 0) Then return 0 else return suma
End Function
Then you can call the function:
code.SumLookup(LookupSet(Fields!Currency_Type.Value, Fields!Currency_Type1.Value,Fields!Gross_Premium_Amount.Value, "DataSet2"))
Yes, Lookup will only return the first matching value. Three options come to mind:
Change your query, so that you only need to get one value: use a GROUP BY and SUM(...) to combine your two rows in the query. If you are using this query other places, then make a copy and change that.
Is there some difference in the rows? Such as one is for last year and one is for this year? If so, create an artificial lookup key and lookup the two values separately:
=Lookup(Fields!Currency_Type.Value & ","
& YEAR(DATEADD(DateInterval.Year,-1,today())),
Fields!Currency_Type1.Value & ","
& Fields!Year.Value,
Fields!Gross_Premium_Amount.Value,
"DataSet2")
+
Lookup(Fields!Currency_Type.Value & ","
& YEAR(today()),
Fields!Currency_Type1.Value & ","
& Fields!Year.Value,
Fields!Gross_Premium_Amount.Value,
"DataSet2")
Use the LookupSet function as mentioned. With this you'll get a collection of the values back, and then need to add those together. The easiest way to do this is with embedded code in the report. Add this function to the report's code:
Function AddList(ByVal items As Object()) As Double
If items Is Nothing Then
Return 0
End If
Dim Total as Double
Total = 0
For Each item As Object In items
Total = Total + CDbl(item)
Next
Return Total
End Function
Now call that with:
=Code.AddList(LookupSet(Fields!Currency_Type.Value,
Fields!Currency_Type1.Value,
Fields!Gross_Premium_Amount.Value,
"DataSet2"))
(Note: this code was not tested. I just composed it in the Stack Overflow edit window & I'm no fan of VB. But it should give you a good idea of what to do.)