简体   繁体   English

Excel找不到要打印的内容

[英]Excel can't find anything to print

I am working on an application, who needs to export data. 我正在开发需要导出数据的应用程序。 I export this data to JSON, DB and after it I create a certificate in excel. 我将此数据导出到JSON,DB,然后在excel中创建证书。

The export to excel and the excel file creation works perfectly, BUT I am not able to print the excel. 导出到excel和excel文件创建工作正常,但是我无法打印excel。 I tried it from my App (VB.NET) and also with VBA (to check if was a problem with my app), but both fails. 我从我的应用程序(VB.NET)以及VBA(检查我的应用程序是否有问题)中进行了尝试,但均失败了。 If I open the file with excel, I am not able to print it and can't see the preview although PrintRange is set. 如果使用excel打开文件,尽管设置了PrintRange,但无法打印,也看不到预览。

I always get 我总是

"Excel couldn't find sth to print" “ Excel找不到要打印的东西”

I tried to print the workbook, the sheet and a range, but always the same. 我尝试打印工作簿,图纸和范围,但始终相同。 I also tried setting worksheet.PageSetup.PrintArea and the same. 我也尝试设置worksheet.PageSetup.PrintArea和相同。 Trying ExportAsFixedFormat doesn't work as well. 尝试ExportAsFixedFormat效果不佳。 I also tried to set all my installed printers as default and nothing, it fails with every printer. 我还尝试将所有已安装的打印机设置为默认打印机,但没有进行任何操作,每台打印机都会失败。

That happens only with this file, any other files print without problems. 仅使用此文件会发生这种情况,其他任何文件都不会出现问题。

If I open the file--go to print--also see an "Nothing to print" instead of the preview, although print range is set. 如果我打开文件(要打印),尽管设置了打印范围,但也会看到“没有要打印的内容”而不是预览。

Now, if I click in a cell, write sth. 现在,如果我单击一个单元格,请写某事。 and delete it or make any interaction, then I am able to see the preview and print the file as well. 并删除它或进行任何交互,然后我就能看到预览并打印文件。

If I save now the working file and try in a simple App to open the file and print it, the bad message comes. 如果我现在保存工作文件并尝试在一个简单的App中打开文件并进行打印,则会出现错误消息。 If I reopen the file in excel, I don't see the preview again and have to interact with the file to be able to print. 如果我在excel中重新打开文件,则不会再看到预览,必须与文件进行交互才能打印。

I have tried all what I could and also searched like crazy but anything has worked. 我尽了一切努力,也疯狂地搜寻着,但一切都奏效了。

I hope someone have had the same issue and can help me, or just knows what I am doing wrong or what is wrong with my excel file, since this is the first time in my life (and work a lot with excel) that I've seen this message. 我希望有人遇到同样的问题并能为我提供帮助,或者只是知道我在做什么或我的excel文件有什么问题,因为这是我一生中第一次(并且在excel中工作很多)我已经看到了此消息。

The export code is a bit long, so I haven't posted it here, but it's sth like this: 导出代码有点长,所以我没有在这里发布它,但是有点像这样:

    Public Shared Function ExportCalibrationAsync(pressureCalibration As PressureCalibration, filePath As String, fileName As String, excelTemplate As Byte()) As Task 'TODO:Refactor...Not use 2.dots
        Return Task.Run(Sub()
                            CheckFileName(fileName)
                            Dim fullPath = Path.Combine(filePath, fileName)
                            Dim tempFileName = Path.GetTempFileName()
                            Dim tempFullPath = Path.Combine(filePath, tempFileName)
                            Dim excel = New Excel.Application()
                            Dim row = 1
                            'Write the passed excel template to a tempFile
                            My.Computer.FileSystem.WriteAllBytes(tempFullPath, excelTemplate, False)
                            Dim excelWorkbooks = excel.Workbooks
                            'Add template workbook to actual workbook
                            Dim excelWorkbook As Excel.Workbook = excelWorkbooks.Open(tempFullPath)

                            '////////////
                            '////Code to Export data to excel
                            '////////////

                            '//ExportAsFixedFormat or Print doesn't work and
                            '//MsgBox pops up with "Excel could not find anything to print"
                            excelWorkSheet.PageSetup.PrintArea="$A$1:$G$40"
                            excelWorkSheet.ExportAsFixedFormat(XlFixedFormatType.xlTypePDF,filePath,XlFixedFormatQuality.xlQualityStandard)
                            excelWorkbook.SaveAs(fullPath)
                            excelWorkbook.Close()
                            excel.Application.Quit()
                            excel.Quit()
                            File.Delete(tempFullPath)
                            GC.Collect()
                            GC.WaitForPendingFinalizers()
                            GC.Collect()
                            GC.WaitForPendingFinalizers()
                            Marshal.ReleaseComObject(calibrationChartObject)

I have a chart in this sheet, but I don't think the chart is the problem, since I can print other files with charts using the same code. 我在此工作表中有一个图表,但我认为该图表不是问题,因为我可以使用相同的代码打印其他带有图表的文件。

I just encountered this same error for the first time. 我只是第一次遇到这个错误。 I realized that I had changed one of the worksheets in the workbook to only print the fourth of four pages, and the same setting was apparently applied to the other worksheets that did not have four pages. 我意识到,我已经更改了工作簿中的一个工作表,仅打印了四页中的第四页,并且显然对没有四页的其他工作表也使用了相同的设置。 Clearing the page numbers (4 of 4) resolved the issue. 清除页码(第4页,共4页)解决了此问题。

I finally (after 2 weeks) find the solution, at least it works for me. 我终于(两周后)找到了解决方案,至少对我有用。

I have saved all the time the file with the pagelayout view activated. 我一直都在激活页面布局视图的情况下保存文件。 The one in the middle in the photo. 照片中间的那个。 预习

Today I was testing again, and I decide to save activate the normal layout and voilá it works!!! 今天,我再次进行测试,我决定保存激活正常的布局,以确保它能正常工作!!!

I've checked and that's definitely the fix...If I activate the pagelayout in any file, save it and try to export it...."Excel couldn't find anything to print". 我已经检查过,绝对可以解决问题。如果我在任何文件中激活pagelayout,请保存并尝试将其导出。...“ Excel找不到要打印的内容”。

It's really weird (at least for me) this error. 这个错误真的很奇怪(至少对我而言)。 If anyone knows if that has a reason tell me...I think is maybe a small bug. 如果有人知道这是否有原因告诉我...我认为这可能是一个小错误。

I have the same issue. 我有同样的问题。 The view is already in Normal layout. 该视图已经处于“普通”布局中。

I found out the issue is due to printing setting: - active sheet - printing pages 我发现问题是由于打印设置:-活动工作表-打印页面

select the sheet intended to be print out, ensure it's the "active sheet" in printing option. 选择要打印的纸张,确保它是打印中的“活动纸张”选项。 don't treat pages as sheet. 不要将页面视为表格。 the pages is the output. 页面是输出。

if the print out from current sheet only 1 page, especially when the scaling is set to "fit sheet to 1 page", there will be no more than 1 page in the output, and attempt to print page from 2 onward will sure have this error. 如果仅从当前工作表打印出1页,尤其是当缩放比例设置为“将工作表调整为1页”时,输出将不超过1页,并且尝试从2开始打印页面将确保具有此功能错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM