Inserting page break using Aspose.cell OR Aspose.Excel - c#

We have a reporting project where in we use the .NET framework to create excel reports on the fly. The different components that are used are System Namespace, Aspose.Cell and Aspose.Excel
We have a report where we execute a certain set of command in a loop. After each loop execution we need to insert a page break. Currently, we use System.Environment to insert line breaks, but I don't see any similar method for page break. Also, I read some where that the Aspose.cell latest version supports page break, but we are using version 4.7.1.0
Can someone advise me on how this can be done?

Although I have ever never worked with Aspose before, I did a quick search and found that there was a VerticalPageBreak object in the object model as shown on the website:
Each Worksheet object contains a VerticalPageBreakCollection object. A VerticalPageBreak object is used to create a vertical page break in the worksheet.
The best way to insert page breaks seems to be by using the VerticalPageBreak Class:
excel.Worksheets[0].VerticalPageBreaks.Add("G5");
Here is a reference to the VerticalPageBreak Class.
This should take care of vertical page breaks.

Related

Cannot retrieve container for XShape in LibreOffice

I'm struggling with some code using LibreOffice 7.1.0 on Windows 10 to append images from a folder into separate slides in Impress. I've been looking here and OpenOffice documentation. This call continuously fails (null): xMultiServiceFactory.createInstance("com.sun.star.drawing.BitmapTable"); and I cannot understand why? I tried using XMultiComponentFactory also, but no luck. Has it got something to do with Slide Layout, but despite being of blank type, I could drag-drop an image and it gets added in the slide.
Unfortunately, full code is on restricted system, so I have this much only. Any hints on potential causes would be very helpful.
It was simple issue: I needed to initialize xMultiServiceFactory with xComponent. I had earlier initialized it with xComponentContext.getServiceManager(). I realize again, this is why learning object model is very important. COM could get tricky unless, one knew what they were doing.

(DevExpress 19.1) How to make text in field a hyperlink? Currently using HyperLinkEdit but can’t seem to make it multiline

I am upgrading the objects on my form to DevExpress tools as opposed to the standard WinForm tools.
I am working with a field that contains hyperlinks only, I originally tried to use a MemoEdit but found out after googling that it wasn’t possible to use hyperlinks in this type of field. I seen the RichEditControl get mentioned in a few places but it seems to open a whole control and I’m just trying to make text in a certain field a hyperlink.
So I’ve ended up at the HyperLinkEdit field and it’s working as hoped apart from the fact that the text isn’t wrapped/multi line, meaning that the text just carries on as a single line so on the larger file paths the characters are hidden after a certain length due to it not wrapping and starting a new line.
Could anyone provide a pointer for this? I checked the properties and nothing has jumped out to me and the fact that there’s no multi line property makes me think there isn’t a way to do this using this type of field.
Edit:

Altering WatiN.Core dll to work with frames AND iframes

Alright so this may be a total n00b question but I'm using the WatiN 2.1 library with Visual Studio 2013 and I'm trying to automate a mostly javascript-based webpage. I've done this task already using VBA but I wanted to redo it in C#. The webpage has multiple AND elements and some necessary fields are contained in lower levels of each. In VBA, I was able to navigate the page by simple doing something like this:
ie.Document.frames("frameID1").Document.frames("frameID2").Document.getElementByID("target").Click
This line of code would work whether frameID1 or frameID2 were frames or iframes. It didn't seem to matter to VBA. I tried a similar approach in C# using WatiN but it seems like the Frame feature in WatiN only recognizes as frame elements and simply recognizes a element as a simple HTML element.
That being said, I have read the question regarding this found here
but this is where my questoin arises. They say the solution is to alter the code for the AllFramesProcessor method and that fixes it. But how exactly do you access and modify this code? This code is contained in a .dll which I've tried to modify using .NET Reflector. I've export the source code, opened it in Visual Studio, found the code to modify and did so, but when I tried to build a new release, it threw multiple errors. Any suggestions on how to modify this block of code properly and get a version of WatiN that can handle elements?

Web automation using C# WebBrowser

I'm in the very early stages of attempting to automate data entry and collection from a website. I have a 16,000 line CSV file. For each line, I'd like to enter data from that line into a textarea on a webpage. The webpage can then perform some calculations with that data and spit out an answer that I'd collect. Specifically, on the webpage http://www.mirbase.org/search.shtml, I'd like to enter a sequence in the sequence text box at the bottom, press the "Search miRNAs" button and then collect results on the next page.
My plan as of right now is to use a C# WebBrowser. My understanding is that I can access the individual elements in the HtmlDocument either by id, name or coordinate. The last option is not ideal, because if I distribute this program to other people I can't be sure they'd be using at the same coordinates. As for the other 2 options, the textarea has a name, but it's the same as the form name, so I don't know how to access it. The button I'd like to click has neither a name nor an id.
Does anyone have any ideas as to how to access the elements I need? I am by no means set on this method, so if there's an easier/better way I'm certainly open to suggestions.
The WebBrowser class is not designed for this, hence why you are coming up with your problems.
You need to look into a tool that is designed for web automation.
Since you are using C#, Selenium has a wonderful set of C# bindings, and it can solve your problems because you'll be to use different locators (locating an element by a CSS selector or XPath specifically).
http://docs.seleniumhq.org/
Check mshtml - Mshtml on msdn
You can use it with the WebBrowser object.
Add Microsoft.mshtml reference to your project and the using mshtml declaration in your class.
Using mshtml you can easily set and get elements properties.

C# How can I create and print a document?

I have a timetable in memory, and need to be able to print it out.
The timetable will likely be many pages, each page will look quite similar:
A grid of cells, across the horizontal axis is time, and along the vertical axis is entities. Cell x, y will contain the allocation of a particular job to entity x at timeslot y.
I'm looking at the System.Drawing.Printing.PrintDocument class but it's incredibly cumbersome. I need to set an event handler to the PrintDocument.PrintPage, yet there doesn't appear to be any way to get the page number from the PrintPageEventArgs?
I just want to construct my document and call some Print() function. I suppose if I could get the page number within the event handler, I could construct the page layout on the fly with e.Graphics and GDI.
I could potentially even put together a HTML page using tables and print that - if I could somehow control what prints on what page?
Is there a better way to construct and print documents in C#?
The target machines do have Office installed, but they're all different versions and I've had lots of trouble getting correct versions of the .Net/Office interop library to work with them.
Edit: I could potentially even create a temporary LaTeX file on the fly and compile it, then print it. This seems like a good solution, except that the target machines are locked and the users can't install new software, hence I would need to bundle the LaTeX compiler with my program, and my compiler is almost 300MB.
Sounds to me like you're giving up too soon. Handling the PrintPage event isn't that difficult and since the event is raised sequentially, all you have to do is keep a page counter in that event. That's how I've done it in the past with MetaFile images (printing Reporting Services reports through a web service call).
I build a similar tool by using the Microsoft Chart Controls, easy to use.
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=130f7986-bf49-4fe5-9ca8-910ae6ea442c&displaylang=en
If you can save it to a file, you can use this here,
Print images c#.net

Categories