Trying to save just one page of a document - save

I want to save just one page of a document but when i try to save it doesn't give me any option and it saves all 15 pages in just one document. Is there any way to do select only one page?

I have a similar code. Maybe this will help you.
Procedure SaveDocument(ObjectDocument) Export
// Printing the first page
SpreadsheetDocument = New SpreadsheetDocument;
SpreadsheetDocument.FitToPage = ObjectDocument.FitToPage;
SpreadsheetDocument.PageOrientation = ObjectDocument.PageOrientation;
SpreadsheetDocument.PrintScale = ObjectDocument.PrintScale;
SpreadsheetDocument.PageSize = ObjectDocument.PageSize;
For counter = 1 To ObjectDocument.TableHeight Do
SpreadsheetDocument.Clear();
SpreadsheetDocument.Put(ObjectDocument.GetArea(1,1,counter,ObjectDocument.TableWidth));
If SpreadsheetDocument.PageCount() > 1 Then
EndOfFirstPage = counter - 1;
Break;
EndIf;
EndDo;
Output(ObjectDocument.GetArea(1,1, EndOfFirstPage, ObjectDocument.TableWidth))
EndProcedure

Related

Pagination issue in Report Viewer 11 in MVC Application

I am using ReportViewer 11 to display a report inside an iframe (aspx page is loaded into iframe). It displays first page properly. But when I click on next page, it loads the first page again. Even if I type in page number manually into the textbox, it loads first page only. It seems like, it doesn't fire the pagenavigation event in the server side. If I set the currentpage property to 2 in code behind, then also it loads page 1 only no matter what settings I provide.
Searched for this for days. Got no solution.
Any help will be appreciated.
Thanks
Apply this logic
Store the records in container1
Pass the records to container2
print 5 records(or may be more) from container2
when "next" button is pressed print next 5 from container2
and so on.
I dont know whether this will help you, but records from database can be paginated in this way.
I have tried this logic too. But the main problem is that ReportViewer.CurrentPage is 0 always (in my case) even when the "next" button is pressed. So it will again show the container1 records. This is my code:
public void SetReportData(ref ReportViewer objRptVwr, ReportParameter[] rptParam, string moduleName, string reportName, string dsName, System.Data.DataTable dtFinal){
objRptVwr.Reset();
objRptVwr.ProcessingMode = ProcessingMode.Local;
objRptVwr.LocalReport.ReportPath = HttpContext.Current.Server.MapPath("~/ReportViewer/" + moduleName + "/" + reportName + ".rdlc");
if (rptParam != null)
objRptVwr.LocalReport.SetParameters(rptParam);
objRptVwr.ShowPrintButton = true;
objRptVwr.ShowParameterPrompts = true;
objRptVwr.AsyncRendering = false;
objRptVwr.InteractivityPostBackMode = InteractivityPostBackMode.AlwaysSynchronous;
objRptVwr.ShowBackButton = true;
objRptVwr.SizeToReportContent = false;
objRptVwr.PageCountMode = PageCountMode.Actual;
objRptVwr.ShowExportControls = true;
objRptVwr.ShowPageNavigationControls = true;
objRptVwr.ShowToolBar = true;
objRptVwr.ShowWaitControlCancelLink = false;
objRptVwr.ShowZoomControl = true;
objRptVwr.LocalReport.EnableExternalImages = true;
objRptVwr.ExportContentDisposition = ContentDisposition.AlwaysInline;
ReportDataSource reportDataSource = new ReportDataSource(dsName, (System.Data.DataTable)dtFinal);
objRptVwr.LocalReport.DataSources.Clear();
objRptVwr.LocalReport.DataSources.Add(reportDataSource);
objRptVwr.LocalReport.Refresh();
}
What I did that the generated buttons will be according to the list size.
Each buttons(may be li tag) will have a textfield containing value like 0,5,10 and so on dynamically(In case of 5 elements per page).
A button is clicked, the value of that textfield(e.g index) I got and shifted the resulset position to index and print the records upto 5 elements.

onFullSync action, show updated info - DHTMLX Grid + RoR

I have a Ruby on Rails project where I use a DHTMLX Grid.
Is there a way of showing, using the event handler "onFullSync" provided by the grid API, to show updated data?
Let me explain a little better... I know I can do something like:
dp.attachEvent("onFullSync", function(){
alert("update complete");
})
But what I want is something more complex. I want to, after each completed update, alter a div adding the information like this:
Field 2 was updated to XYZ and field 3 was updated to XER on line X
Field 1 was updated to 123 and field 3 was updated to XSD on line Y
Is this possible?
Thanks
There is a onAfterUpdate event that can be used similar to onFullSync
http://docs.dhtmlx.com/api__dataprocessor_onafterupdate_event.html
It will fire after each data saving operation ( if you are saving 5 rows - it will fire 5 times )
Still, info about updated columns will not be available here.
Also, you can try onEditCell event of grid. It fires after changing data in db, but before real saving in database. Here you can get all necessary info - row, column, old value and new value.
http://docs.dhtmlx.com/api__link__dhtmlxtreegrid_oneditcell_event.html
So, what I end up doing was:
After creating the grid I created an array:
var samples = [];
Then, as per #Aquatic suggestion, I added to "onEditCell" event the following line:
samples[samples.length] = grid.cells(rId, 5).getValue();
This allowed me to add to the array the value present on column 5 of the row changed. Then, on "onFullSync" event I hide or show the div created on the view with the messages (I distinguish if it's on row or more changed on the grid).
//Deals with messages after update
dp.attachEvent("onFullSync", function(){
unique_samples = uniq_fast(samples.sort());
if (unique_samples.length == 1){
$('#updated-samples').text("");
$(".messages").show();
$('#updated-samples').text("A seguinte amostra foi actualizada: " + unique_samples[0]);
//to clear the array
samples = [];
} else if (unique_samples.length > 1){
$('#updated-samples').text("");
$(".messages").show();
$('#updated-samples').text("As seguintes amostras foram actualizadas: " + unique_samples.sort().join(", "));
//to clear the array
samples = [];
} else {
$('#updated-samples').text("");
$(".messages").hide();
//to clear the array
samples = [];
}
})
The problem with using "onEditCell" is that everytime a field is changed on that row I get a repeated value on my "samples" array, I I had to remove duplicate from that array. For that I used one of the suggestions at this answer
// remove duplicates in array
function uniq_fast(a) {
var seen = {};
var out = [];
var len = a.length;
var j = 0;
for(var i = 0; i < len; i++) {
var item = a[i];
if(seen[item] !== 1) {
seen[item] = 1;
out[j++] = item;
}
}
return out;
}
Then I have on the beginning of the view, to show the messages:
<div class="alert alert-success messages" id="updated-samples">
And that's it. I could be not the most efficient way but it works for what I wanted. I will leave the question open a few more days to see if any other option appears.

How can I protect an excel sheet, except for a particular cell using Open XML 2.0?

I am generating a report using OpenXML and exporting it to excel. I want to protect the excel sheet except for a particular cell.
If anyone has worked on this before, kindly help
Thanks,
Amolik
PageMargins pageM = worksheetPart.Worksheet.GetFirstChild<PageMargins>();
SheetProtection sheetProtection = new SheetProtection();
sheetProtection.Password = "CC";
sheetProtection.Sheet = true;
sheetProtection.Objects = true;
sheetProtection.Scenarios = true;
ProtectedRanges pRanges = new ProtectedRanges();
ProtectedRange pRange = new ProtectedRange();
ListValue<StringValue> lValue = new ListValue<StringValue>();
lValue.InnerText = "A1:E1"; //set cell which you want to make it editable
pRange.SequenceOfReferences = lValue;
pRange.Name = "not allow editing";
pRanges.Append(pRange);
worksheetPart.Worksheet.InsertBefore(sheetProtection, pageM);
worksheetPart.Worksheet.InsertBefore(pRanges, pageM);
ref : http://social.msdn.microsoft.com/Forums/en-US/a6f7502d-3867-4d5b-83a9-b4e0e211068f/how-to-lock-specific-columns-in-xml-workbook-while-exporting-dataset-to-excel?forum=oxmlsdk
Have you tried using the OpenXML Productivity Toolkit?
from what I can see you have to add a
new CellFormat
with attribute
ApplyProtection = true
to
CellFormats
append
new Protection
with attribute
Locked = false
to the the CellFormat you created.
CellFormat is a element of CellFormats which is a element of Stylesheet
then to the Worksheet you add a
new SheetProtection(){ Password = "CC1A", Sheet = true, Objects = true, Scenarios = true };
I havent tried this, but it should be easy enought to find out what you need to do with the Productivity Toolkit. I hope this points you and anyone trying to do this in the right direction.

Programmatically added SummaryLinkWebPart doesn't display Links

I am using below code to Add SummaryLinkWebPart to a Page and also adding few links to that wehbpart. I can see the webpart now on the page but it doesn't have any links inside it. Does anyone know what is wrong with the code?
var wpm = web.GetLimitedWebPartManager("Pages/default.aspx", PersonalizationScope.Shared);
SummaryLinkWebPart slwp = new SummaryLinkWebPart();
for (int counter = 0; counter < list.ItemCount; counter++)
{
urlField = list.Items[counter]["URL"].ToString().Split(',');
SummaryLink link = new SummaryLink(urlField[1].Trim());
slwp.SummaryLinkValue.SummaryLinks.Add(link);
slwp.SummaryLinkValue.SummaryLinks[counter].OpenInNewWindow = true;
slwp.SummaryLinkValue.SummaryLinks[counter].LinkUrl = urlField[0].Trim();
slwp.SummaryLinkValue.SummaryLinks[counter].Description = urlField[1];
slwp.Style = "Image on left";
Console.WriteLine(link.LinkUrl + link.Title);
}
wpm.AddWebPart(slwp, lvwp.ZoneID, slwp.ZoneIndex + 1);
Hmm this seems to be the hack but the only thing that solves this issue is reassigning the SummaryLinkValue Property back again its value.
slwp.SummaryLinkValue = slwp.SummaryLinkValue;
use
SPLimitedWebPartManager wpManager = page.GetLimitedWebPartManager(System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
then when done call page.Update(). something like this
SPFile page = web.GetFile(string.Format("Pages/{0}", this.FileName.Replace("html", "aspx")));
SPLimitedWebPartManager wpManager = page.GetLimitedWebPartManager(System.Web.UI.WebControls.WebParts.PersonalizationScope.Shared);
SummaryLinkWebPart webpart = new SummaryLinkWebPart();
if (!string.IsNullOrEmpty(RelatedTopic1))
webpart.SummaryLinkValue.SummaryLinks.Add(GetSummaryLink(web, pages, RelatedTopic1));
if (!string.IsNullOrEmpty(RelatedTopic2))
webpart.SummaryLinkValue.SummaryLinks.Add(GetSummaryLink(web, pages, RelatedTopic2));
if (!string.IsNullOrEmpty(RelatedTopic3))
webpart.SummaryLinkValue.SummaryLinks.Add(GetSummaryLink(web, pages, RelatedTopic3));
if (!string.IsNullOrEmpty(RelatedTopic4))
webpart.SummaryLinkValue.SummaryLinks.Add(GetSummaryLink(web, pages, RelatedTopic4));
if (webpart.SummaryLinkValue.SummaryLinks.Count > 0)
{
wpManager.AddWebPart(webpart, "BottomPanel", 0);
page.Update();
}

Is it possible to use an offset when using the Symfony sfPager class?

I would like to disregard the first n items in a pager list of items. I.e. they are being used elsewhere in the design.
So my pager list needs to be as such:
Page 1: Items 8 - 17
Page 2: Items 18 - 27
Page 3: Items 28 - 37
...
However, setting an offset or limit in the criteria object does nothing. I presume they are used by the pager itself.
Is it possible to add a offset to the pager class in some other way?
Ok, I have got around the problem by modifying sfPropelPager.class.php and putting it into a new class file which I have named atPropelPagerOffset.class.php
It works in exactly the same way apart from it takes an extra parameter, $offset
So the top of the file looks like:
protected
$criteria = null,
$peer_method_name = 'doSelect',
$peer_count_method_name = 'doCount',
$offset = 0;
public function __construct($class, $maxPerPage = 10, $offset = 0)
{
parent::__construct($class, $maxPerPage);
$this->setCriteria(new Criteria());
$this->tableName = constant($class.'Peer::TABLE_NAME');
$this->offset = $offset;
}
Then I have made this tiny change around line 50
$c->setOffset($offset+$this->offset);
Works a treat!
Simpler solution would be a custom select method:
$pager->setPeerMethod('doSelectCustom');
and then put your logic in the model Peer Class:
public static function doSelectCustom($c)
{
$c2 = clone $c;
$offset = $c2->getOffset();
$limit = $c2->getLimit();
$someCustomVar = someClass::someMethod();
if ($offset == 0) // we are in the first page
{
$c2->setLimit($limit - $someCustomVar);
$c2->add(self::SOMECOLUMN, false);
} else $c2->setOffset($offset - $someCustomVar);
return self::doSelectRS($c2); // or doSelect if you wanna retrieve objects
}

Resources